Skip to content

Commit c6e2048

Browse files
ante012ante
authored and
ante
committed
BUG: fillna returns frame when inplace=True if value is a dict (pandas-dev#16156)
1 parent 95f4f7d commit c6e2048

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

pandas/core/generic.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4054,7 +4054,7 @@ def fillna(self, value=None, method=None, axis=None, inplace=False,
40544054
continue
40554055
obj = result[k]
40564056
obj.fillna(v, limit=limit, inplace=True, downcast=downcast)
4057-
return result
4057+
return result if not inplace else None
40584058
elif not is_list_like(value):
40594059
new_data = self._data.fillna(value=value, limit=limit,
40604060
inplace=inplace,

pandas/tests/frame/test_missing.py

+5
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,9 @@ def test_fillna_inplace(self):
407407
df.fillna(value=0, inplace=True)
408408
tm.assert_frame_equal(df, expected)
409409

410+
expected = df.fillna(value={0:0}, inplace=True)
411+
assert expected is None
412+
410413
df[1][:4] = np.nan
411414
df[3][-4:] = np.nan
412415
expected = df.fillna(method='ffill')
@@ -415,6 +418,8 @@ def test_fillna_inplace(self):
415418
df.fillna(method='ffill', inplace=True)
416419
tm.assert_frame_equal(df, expected)
417420

421+
422+
418423
def test_fillna_dict_series(self):
419424
df = DataFrame({'a': [nan, 1, 2, nan, nan],
420425
'b': [1, 2, 3, nan, nan],

pandas/tests/series/test_missing.py

+3
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,9 @@ def test_fillna_inplace(self):
513513
expected = x.fillna(value=0)
514514
assert_series_equal(y, expected)
515515

516+
expected = x.fillna(value={'a' : 0}, inplace=True)
517+
assert expected is None
518+
516519
def test_fillna_invalid_method(self):
517520
try:
518521
self.ts.fillna(method='ffil')

0 commit comments

Comments
 (0)