Skip to content
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

BUG: Fixed strange behaviour of pd.DataFrame.drop() with inplace argu… #30501

Merged
merged 28 commits into from
Mar 26, 2020
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
55ababc
BUG: Fixed strange behaviour of pd.DataFrame.drop() with inplace argu…
Dec 27, 2019
1dc7e72
Revert "DOC: standardize wording for changed default args (#30493)"
Dec 27, 2019
3c48c5d
Merge branch 'master' of https://github.com/pandas-dev/pandas
Dec 28, 2019
665fa27
moved new test to test_operators.py and added new bool argument to ND…
Dec 29, 2019
cc5e480
fixed black formatting
Dec 29, 2019
35e3e0f
Merge branch 'master' into master
rjfs Jan 27, 2020
d2a8b90
moved and refactored new test; implemented new solution by resetting …
Jan 27, 2020
72d3815
Merge branch 'master' of https://github.com/rjfs/pandas
Jan 27, 2020
f0dbe12
removed some old changes
Jan 27, 2020
00a5c7f
removed some old changes
Jan 27, 2020
f33f55f
removed some old changes
Jan 27, 2020
27cbd51
Update v1.0.0.rst
rjfs Jan 27, 2020
ddf890f
Update v1.0.0.rst
rjfs Jan 27, 2020
a5182f4
Merge remote-tracking branch 'upstream/master'
Feb 10, 2020
a199bdf
Merge branch 'master' of https://github.com/rjfs/pandas
Feb 10, 2020
987c274
Merge remote-tracking branch 'upstream/master'
Mar 7, 2020
0b979f9
restructured test
Mar 7, 2020
5b59b01
Merge remote-tracking branch 'upstream/master'
Mar 14, 2020
53cd24a
Update v1.1.0.rst
rjfs Mar 14, 2020
a7ce080
Merge remote-tracking branch 'upstream/master'
Mar 14, 2020
54bf552
Merge remote-tracking branch 'upstream/master'
Mar 14, 2020
aed33ba
Merge branch 'master' into master
rjfs Mar 14, 2020
7a558ad
Merge branch 'master' into master
jreback Mar 25, 2020
7c08e9b
Merge branch 'master' into master
rjfs Mar 26, 2020
76131c0
merged with master
Mar 26, 2020
a220dc4
Merge remote-tracking branch 'upstream/master'
Mar 26, 2020
5606519
merge with master
Mar 26, 2020
9bdf454
merge with master
Mar 26, 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
3 changes: 2 additions & 1 deletion pandas/core/ops/methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ def _wrap_inplace_method(method):

def f(self, other):
result = method(self, other)

# Delete cacher
self._reset_cacher()
# this makes sure that we are aligned like the input
# we are updating inplace so we want to ignore is_copy
self._update_inplace(
Expand Down
19 changes: 19 additions & 0 deletions pandas/tests/frame/test_axis_select_reindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -1152,3 +1152,22 @@ def test_drop_non_empty_list(self, index, drop_labels):
# GH 21494
with pytest.raises(KeyError, match="not found in axis"):
pd.DataFrame(index=index).drop(drop_labels)

@pytest.mark.parametrize(
"operation", ["__iadd__", "__isub__", "__imul__", "__ipow__"]
)
@pytest.mark.parametrize("inplace", [False, True])
def test_inplace_drop_and_operation(self, operation, inplace):
# GH 30484
data_dict = {"x": [1, 2, 3, 4, 5], "y": [10, 20, 30, 40, 50]}
df = pd.DataFrame(data_dict)
y = df["y"]

if inplace:
df.drop("y", axis=1, inplace=inplace)
else:
df = df.drop("y", axis=1, inplace=inplace)
# Perform operation and ensure that df is not changed
expected = df.copy()
rjfs marked this conversation as resolved.
Show resolved Hide resolved
getattr(y, operation)(1)
tm.assert_frame_equal(df, expected)