Skip to content

Commit

Permalink
BUG: fillna returns frame when inplace=True if value is a dict (panda…
Browse files Browse the repository at this point in the history
  • Loading branch information
ante328 authored and alanbato committed Nov 10, 2017
1 parent 17564f3 commit 5d19e7a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion doc/source/whatsnew/v0.21.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ Conversion
- 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`)
- 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`)
- Bug in ``IntervalIndex.is_non_overlapping_monotonic`` when intervals are closed on both sides and overlap at a point (:issue:`16560`)

- Bug in :func:`Series.fillna` returns frame when ``inplace=True`` and ``value`` is dict (:issue:`16156`)

Indexing
^^^^^^^^
Expand Down
3 changes: 2 additions & 1 deletion pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -4135,7 +4135,8 @@ def fillna(self, value=None, method=None, axis=None, inplace=False,
continue
obj = result[k]
obj.fillna(v, limit=limit, inplace=True, downcast=downcast)
return result
return result if not inplace else None

elif not is_list_like(value):
new_data = self._data.fillna(value=value, limit=limit,
inplace=inplace,
Expand Down
3 changes: 3 additions & 0 deletions pandas/tests/frame/test_missing.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,9 @@ def test_fillna_inplace(self):
df.fillna(value=0, inplace=True)
tm.assert_frame_equal(df, expected)

expected = df.fillna(value={0: 0}, inplace=True)
assert expected is None

df[1][:4] = np.nan
df[3][-4:] = np.nan
expected = df.fillna(method='ffill')
Expand Down

0 comments on commit 5d19e7a

Please sign in to comment.