-
-
Notifications
You must be signed in to change notification settings - Fork 18k
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
REGR: properly update DataFrame cache in Series.__setitem__ #48215
Changes from 6 commits
0f7f932
f8805df
b567d02
253a7a5
2ec2673
f32ef47
8c75621
3dc008a
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 |
---|---|---|
|
@@ -1235,3 +1235,21 @@ def test_setitem_not_operating_inplace(self, value, set_value, indexer): | |
view = df[:] | ||
df[indexer] = set_value | ||
tm.assert_frame_equal(view, expected) | ||
|
||
@td.skip_array_manager_invalid_test | ||
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 skips whereas Now this test fails with so it does make sense to just skip. but are we likely to want a similar test for array manger? 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, I think it indeed makes sense to skip this test instead of xfail, since the way is written is not intended to ever work for ArrayManager. But so we could indeed write a separate test that checks for the the ArrayManager case (but I would say it's maybe not a super high priority, I can only take a look in the weekend). 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.
no problem. not a blocker. |
||
def test_setitem_column_update_inplace(self, using_copy_on_write): | ||
# https://github.com/pandas-dev/pandas/issues/47172 | ||
|
||
labels = [f"c{i}" for i in range(10)] | ||
df = DataFrame({col: np.zeros(len(labels)) for col in labels}, index=labels) | ||
values = df._mgr.blocks[0].values | ||
|
||
for label in df.columns: | ||
df[label][label] = 1 | ||
|
||
if not using_copy_on_write: | ||
# diagonal values all updated | ||
assert np.all(values[np.arange(10), np.arange(10)] == 1) | ||
else: | ||
# original dataframe not updated | ||
assert np.all(values[np.arange(10), np.arange(10)] == 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.
Series.__setitem__
doesn't render? so perhaps reword and maybe should also mention memory leak or that the values were not updated inplace using chained indexing with assignment?