-
-
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
Changes from 4 commits
2ae7656
de867c0
d2b9181
441a3e0
dfc63dc
f1bafef
0dc971a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe 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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more.
yes we should do that but as a followon (to capture all _copy) tests. |
||
df = DataFrame({"a": [1]}) | ||
|
||
df["x"] = [0] | ||
df["a"] | ||
|
||
df.copy() | ||
|
||
df["a"].values[0] = -1 | ||
|
||
assert df["a"].values[0] == -1 | ||
tm.assert_frame_equal(df, DataFrame({"a": [-1], "x": [0]})) | ||
|
||
df["y"] = 0 | ||
|
||
assert df["a"].values[0] == -1 | ||
tm.assert_frame_equal(df, DataFrame({"a": [-1], "x": [0], "y": [0]})) |
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.