-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Maintain inplace operation on series #36498
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 all commits
1497988
b2b9bd6
f7b0893
816425c
8494202
e9d6447
7277d38
5cbe60f
dc5e8a1
acb3c02
ffc051f
8640237
56a4c88
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 |
---|---|---|
|
@@ -1317,3 +1317,13 @@ def test_dataframe_div_silenced(): | |
) | ||
with tm.assert_produces_warning(None): | ||
pdf1.div(pdf2, fill_value=0) | ||
|
||
|
||
def test_inplace_arithmetic_operation_on_series_updating_parent_dataframe(): | ||
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 test passes for me on master. is there another case that fails? 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 need to test
but the output of __repr__ and also other ops is incorrect so should also compare using assert_frame_equal
but this should pass with the fix here |
||
# https://github.com/pandas-dev/pandas/issues/36373 | ||
df = pd.DataFrame({"A": [1, 2, 3]}) | ||
s = df["A"] | ||
s += 1 | ||
assert s is df["A"] | ||
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. can we also 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 guess if we do this we no longer need the cacher machinery. At first glance his appears a big change so will open a separate PR as an alternative to this one. |
||
expected = pd.DataFrame({"A": [2, 3, 4]}) | ||
tm.assert_frame_equal(df, expected) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -888,22 +888,6 @@ def test_identity_slice_returns_new_object(self): | |
original_series[:3] = [7, 8, 9] | ||
assert all(sliced_series[:3] == [7, 8, 9]) | ||
|
||
def test_loc_copy_vs_view(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. see #15631 (comment) 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. umm pls revert this test. |
||
# GH 15631 | ||
x = DataFrame(zip(range(3), range(3)), columns=["a", "b"]) | ||
|
||
y = x.copy() | ||
q = y.loc[:, "a"] | ||
q += 2 | ||
|
||
tm.assert_frame_equal(x, y) | ||
|
||
z = x.copy() | ||
q = z.loc[x.index, "a"] | ||
q += 2 | ||
|
||
tm.assert_frame_equal(x, z) | ||
|
||
def test_loc_uint64(self): | ||
# GH20722 | ||
# Test whether loc accept uint64 max value as index. | ||
|
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 was added to fix an existing bug (see #30501) so removing it would likely cause a regression
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.
could this have been the incorrect location for the original fix? it appears there were a couple of iterations in #30501.