Skip to content

BUG: item_cache invalidation in get_numeric_data #35882

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

Merged
merged 21 commits into from
Sep 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
4c5eddd
REF: remove unnecesary try/except
jbrockmendel Aug 21, 2020
c632c9f
Merge branch 'master' of https://github.com/pandas-dev/pandas into re…
jbrockmendel Aug 21, 2020
9e64be3
Merge branch 'master' of https://github.com/pandas-dev/pandas into re…
jbrockmendel Aug 21, 2020
42649fb
TST: add test for agg on ordered categorical cols (#35630)
mathurk1 Aug 21, 2020
47121dd
TST: resample does not yield empty groups (#10603) (#35799)
tkmz-n Aug 21, 2020
1decb3e
revert accidental rebase
jbrockmendel Aug 22, 2020
57c5dd3
Merge branch 'master' of https://github.com/pandas-dev/pandas into ma…
jbrockmendel Aug 22, 2020
a358463
Merge branch 'master' of https://github.com/pandas-dev/pandas into ma…
jbrockmendel Aug 23, 2020
ffa7ad7
Merge branch 'master' of https://github.com/pandas-dev/pandas into ma…
jbrockmendel Aug 23, 2020
e5e98d4
Merge branch 'master' of https://github.com/pandas-dev/pandas into ma…
jbrockmendel Aug 24, 2020
408db5a
Merge branch 'master' of https://github.com/pandas-dev/pandas into ma…
jbrockmendel Aug 24, 2020
0ab1821
BUG: item_cache invalidation in get_numeric_data
jbrockmendel Aug 25, 2020
355800f
Merge branch 'master' of https://github.com/pandas-dev/pandas into bu…
jbrockmendel Aug 25, 2020
71bba9c
Merge branch 'master' of https://github.com/pandas-dev/pandas into bu…
jbrockmendel Aug 25, 2020
58d64d7
Merge branch 'master' of https://github.com/pandas-dev/pandas into bu…
jbrockmendel Aug 25, 2020
505b4bb
Merge branch 'master' of https://github.com/pandas-dev/pandas into bu…
jbrockmendel Aug 26, 2020
3778d1f
whatsnew
jbrockmendel Aug 26, 2020
f31f115
dummy commit to force Travis
jbrockmendel Aug 27, 2020
aeefef3
Merge branch 'master' of https://github.com/pandas-dev/pandas into bu…
jbrockmendel Sep 2, 2020
ba4fc44
Merge branch 'master' of https://github.com/pandas-dev/pandas into bu…
jbrockmendel Sep 2, 2020
9dd4eba
Merge branch 'master' of https://github.com/pandas-dev/pandas into bu…
jbrockmendel Sep 3, 2020
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
1 change: 1 addition & 0 deletions doc/source/whatsnew/v1.1.2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Bug fixes
- Bug in :meth:`DateTimeIndex.format` and :meth:`PeriodIndex.format` with ``name=True`` setting the first item to ``"None"`` where it should be ``""`` (:issue:`35712`)
- Bug in :meth:`Float64Index.__contains__` incorrectly raising ``TypeError`` instead of returning ``False`` (:issue:`35788`)
- Bug in :class:`DataFrame` indexing returning an incorrect :class:`Series` in some cases when the series has been altered and a cache not invalidated (:issue:`33675`)
- Bug in :meth:`DataFrame.corr` causing subsequent indexing lookups to be incorrect (:issue:`35882`)

.. ---------------------------------------------------------------------------

Expand Down
1 change: 0 additions & 1 deletion pandas/core/internals/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,6 @@ def get_numeric_data(self, copy: bool = False) -> "BlockManager":
copy : bool, default False
Whether to copy the blocks
"""
self._consolidate_inplace()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you are removing this then get_bool_data right above looks suspicious.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i agree. thats part of the _reduce trouble we discussed this afternoon. #34918 removes that usage.

return self._combine([b for b in self.blocks if b.is_numeric], copy)

def _combine(self: T, blocks: List[Block], copy: bool = True) -> T:
Expand Down
17 changes: 17 additions & 0 deletions pandas/tests/frame/methods/test_cov_corr.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,23 @@ def test_corr_nullable_integer(self, nullable_column, other_column, method):
expected = pd.DataFrame(np.ones((2, 2)), columns=["a", "b"], index=["a", "b"])
tm.assert_frame_equal(result, expected)

def test_corr_item_cache(self):
# Check that corr does not lead to incorrect entries in item_cache
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there an open issue for this? If not can you add a whatsnew?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whatsnew added


df = pd.DataFrame({"A": range(10)})
df["B"] = range(10)[::-1]

ser = df["A"] # populate item_cache
assert len(df._mgr.blocks) == 2

_ = df.corr()

# Check that the corr didnt break link between ser and df
ser.values[0] = 99
assert df.loc[0, "A"] == 99
assert df["A"] is ser
assert df.values[0, 0] == 99


class TestDataFrameCorrWith:
def test_corrwith(self, datetime_frame):
Expand Down