Skip to content

Commit c5ed358

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

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

doc/source/whatsnew/v0.21.0.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ Conversion
314314
- Fix :func:`DataFrame.memory_usage` to support PyPy. Objects on PyPy do not have a fixed size, so an approximation is used instead (:issue:`17228`)
315315
- Fixed the return type of ``IntervalIndex.is_non_overlapping_monotonic`` to be a Python ``bool`` for consistency with similar attributes/methods. Previously returned a ``numpy.bool_``. (:issue:`17237`)
316316
- Bug in ``IntervalIndex.is_non_overlapping_monotonic`` when intervals are closed on both sides and overlap at a point (:issue:`16560`)
317-
317+
- Bug in :func:`Series.fillna` returns frame when ``inplace=True`` and ``value`` is dict (:issue:`16156`)
318318

319319
Indexing
320320
^^^^^^^^

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)