Skip to content

Commit bfdf22d

Browse files
committed
BUG: core/generic/_update_inplace not resetting item_cache (GH5628)
1 parent c239b06 commit bfdf22d

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

doc/source/release.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ Improvements to existing features
209209
- ``NDFrame.drop()``, ``NDFrame.dropna()``, and ``.drop_duplicates()`` all
210210
accept ``inplace`` as a kewyord argument; however, this only means that the
211211
wrapper is updated inplace, a copy is still made internally.
212-
(:issue:`1960`, :issue:`5247`, and related :issue:`2325` [still not
212+
(:issue:`1960`, :issue:`5247`, :issue:`5628`, and related :issue:`2325` [still not
213213
closed])
214214
- Fixed bug in `tools.plotting.andrews_curvres` so that lines are drawn grouped
215215
by color as expected.

pandas/core/generic.py

+1
Original file line numberDiff line numberDiff line change
@@ -1217,6 +1217,7 @@ def _update_inplace(self, result):
12171217
# NOTE: This does *not* call __finalize__ and that's an explicit
12181218
# decision that we may revisit in the future.
12191219
self._reset_cache()
1220+
self._clear_item_cache()
12201221
self._data = result._data
12211222
self._maybe_update_cacher()
12221223

pandas/tests/test_frame.py

+7
Original file line numberDiff line numberDiff line change
@@ -6806,6 +6806,13 @@ def test_drop(self):
68066806
assert_frame_equal(nu_df.drop('X', axis='rows'), nu_df.ix[["Y"], :])
68076807
assert_frame_equal(nu_df.drop(['X', 'Y'], axis=0), nu_df.ix[[], :])
68086808

6809+
# inplace cache issue
6810+
# GH 5628
6811+
df = pd.DataFrame(np.random.randn(10,3), columns=list('abc'))
6812+
expected = df[~(df.b>0)]
6813+
df.drop(labels=df[df.b>0].index, inplace=True)
6814+
assert_frame_equal(df,expected)
6815+
68096816
def test_fillna(self):
68106817
self.tsframe['A'][:5] = nan
68116818
self.tsframe['A'][-5:] = nan

0 commit comments

Comments
 (0)