Skip to content

Commit 402d983

Browse files
committed
add test case for frame
1 parent 309216c commit 402d983

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

pandas/tests/frame/test_replace.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,20 @@ def test_replace_list(self):
605605

606606
assert_frame_equal(res, expec)
607607

608+
def test_replace_with_empty_list(self):
609+
# GH 21977
610+
s = pd.Series([['a', 'b'], np.nan, [1]])
611+
df = pd.DataFrame({'col': s})
612+
613+
expected = df
614+
result = df.replace([], np.nan)
615+
assert_frame_equal(result, expected)
616+
# GH 19266
617+
with tm.assert_raises_regex(NotImplementedError, 'Replace with array'):
618+
df.replace({np.nan: []})
619+
with tm.assert_raises_regex(NotImplementedError, 'Replace with array'):
620+
df.replace({np.nan: ['dummy', 'alt']})
621+
608622
def test_replace_series_dict(self):
609623
# from GH 3064
610624
df = DataFrame({'zero': {'a': 0.0, 'b': 1}, 'one': {'a': 2.0, 'b': 0}})

0 commit comments

Comments
 (0)