-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: DataFrame._item_cache not cleared on on .copy() #33299
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
Conversation
Co-Authored-By: MomIsBestFriend <[email protected]>
pandas/tests/generic/test_generic.py
Outdated
@@ -910,3 +910,21 @@ def test_axis_classmethods(self, box): | |||
assert obj._get_axis_number(v) == box._get_axis_number(v) | |||
assert obj._get_axis_name(v) == box._get_axis_name(v) | |||
assert obj._get_block_manager_axis(v) == box._get_block_manager_axis(v) | |||
|
|||
def test_cache_on_copy(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should go in tests/frame/methods/test_copy.py
can you make sure the stuff being done below is the minimal amount of stuff needed to trigger the bug in the status quo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked and it seems the minimal amount is being done to trigger the bug. The reason df["y"] = [0] is added is because it causes df["a"].values[0] to be incorrect in addition to df when the cache is not invalidated on copy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should go in tests/frame/methods/test_copy.py
yes we should do that but as a followon (to capture all _copy) tests.
|
||
|
||
class TestCopy: | ||
def test_cache_on_copy(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
put this in pandas/tests/frame/methods/test_api with the rest of the copy tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I only see other copy tests in pandas/tests/frame/test_api.py. I'll assume you mean that one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
|
||
|
||
class TestCopy: | ||
def test_cache_on_copy(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add the issue number as a comment as well as a 1-line expl
doc/source/whatsnew/v1.1.0.rst
Outdated
@@ -363,6 +363,7 @@ Indexing | |||
- Bug in :class:`Index` constructor where an unhelpful error message was raised for ``numpy`` scalars (:issue:`33017`) | |||
- Bug in :meth:`DataFrame.lookup` incorrectly raising an ``AttributeError`` when ``frame.index`` or ``frame.columns`` is not unique; this will now raise a ``ValueError`` with a helpful error message (:issue:`33041`) | |||
- Bug in :meth:`DataFrame.iloc.__setitem__` creating a new array instead of overwriting ``Categorical`` values in-place (:issue:`32831`) | |||
- Bug in :meth:`DataFrame.copy` _item_cache invalidated after copy performs consolidation (:issue:`31784`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you elaborate on what the user affects are here.
lgtm. merging pending doc-build merge (so nothing to do @neilkg ) |
thanks @neilkg |
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff