Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: fillna returns frame when inplace=True if value is a dict (#16156) #17279

Merged
merged 1 commit into from
Aug 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -314,7 +314,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 @@ -4054,7 +4054,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