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