From 390f62f83316ea5476da84b1dbc504d3a96367dc Mon Sep 17 00:00:00 2001 From: Pedro M Duarte Date: Mon, 14 Mar 2016 21:25:03 -0700 Subject: [PATCH] BUG: GH12624 where Panel.fillna() ignores inplace=True Fixes #12624 Author: Pedro M Duarte --- doc/source/whatsnew/v0.18.1.txt | 2 ++ pandas/core/generic.py | 3 ++- pandas/tests/test_panel.py | 6 ++++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v0.18.1.txt b/doc/source/whatsnew/v0.18.1.txt index dbe446f0a7b4f..767dd76373017 100644 --- a/doc/source/whatsnew/v0.18.1.txt +++ b/doc/source/whatsnew/v0.18.1.txt @@ -89,3 +89,5 @@ Bug Fixes ~~~~~~~~~ - Bug in ``value_counts`` when ``normalize=True`` and ``dropna=True`` where nulls still contributed to the normalized count (:issue:`12558`) + +- Bug in ``Panel.fillna`` was ignoring the ``inplace=True`` option. (:issue:`12624`) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 963c953154b57..50e1b21011a92 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -3122,7 +3122,8 @@ def fillna(self, value=None, method=None, axis=None, inplace=False, elif self.ndim == 3: # fill in 2d chunks - result = dict([(col, s.fillna(method=method, value=value)) + result = dict([(col, s.fillna(method=method, value=value, + inplace=inplace)) for col, s in self.iteritems()]) return self._constructor.from_dict(result).__finalize__(self) diff --git a/pandas/tests/test_panel.py b/pandas/tests/test_panel.py index 0a1e15921dad7..b037b519b485f 100644 --- a/pandas/tests/test_panel.py +++ b/pandas/tests/test_panel.py @@ -1528,6 +1528,12 @@ def test_fillna(self): p.iloc[0:2, 0:2, 0:2] = np.nan self.assertRaises(NotImplementedError, lambda: p.fillna(999, limit=1)) + def test_fillna_inplace(self): + panel = self.panel.copy() + panel.fillna(method='backfill', inplace=True) + assert_frame_equal(panel['ItemA'], + self.panel['ItemA'].fillna(method='backfill')) + def test_ffill_bfill(self): assert_panel_equal(self.panel.ffill(), self.panel.fillna(method='ffill'))