Skip to content

Commit 9af801a

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

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

doc/source/whatsnew/v0.21.0.txt

+1
Original file line numberDiff line numberDiff line change
@@ -391,3 +391,4 @@ Other
391391
- Bug in :func:`eval` where the ``inplace`` parameter was being incorrectly handled (:issue:`16732`)
392392
- Bug in ``.isin()`` in which checking membership in empty ``Series`` objects raised an error (:issue:`16991`)
393393
- Bug in :func:`unique` where checking a tuple of strings raised a ``TypeError`` (:issue:`17108`)
394+
- Bug in :func: `fillna` returns frame when ``inplace=True`` and ``value`` is dict (:issue:`16156`)

pandas/core/generic.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -4054,7 +4054,8 @@ 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
4058+
40584059
elif not is_list_like(value):
40594060
new_data = self._data.fillna(value=value, limit=limit,
40604061
inplace=inplace,

pandas/tests/frame/test_missing.py

+3
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')

0 commit comments

Comments
 (0)