DEPR: deprecate inplace keyword in the DataFrame.drop() method#65683
DEPR: deprecate inplace keyword in the DataFrame.drop() method#65683tamhahn wants to merge 17 commits into
Conversation
…-tracking branch 'upstream/main' into depr_inplace_drop
…ream/main' into depr_inplace_drop
…n' into depr_inplace_drop_v2
|
Sorry, a test failed right away. I will look into it and update. Could you please disregard this PR for now. |
| return df.drop_duplicates(subset=cols[:-1]) | ||
|
|
||
|
|
||
| @pytest.mark.filterwarnings("ignore:The inplace keyword in DataFrame.drop is") |
There was a problem hiding this comment.
I think for this test, you could also update the test to not use inplace (from a quick look, I think the test is not really about the inplace drop, but it is using that to construct the expected result of the indexing operation)
Yes, good call (we should not be using
No worries, currently CI is failing for pyarrow and numpy nightly, and that is not related to the changes here and also happening on other PRs |
|
Thank you very much, Joris! I have also removed the use of drop with inplace in the test file you highlighted ([pandas/tests/indexing/multiindex/test_indexing_slow.py as you suggested. The test did have an assert statement ensuring that df.drop with inplace=true returns None but that was already covered in other tests, so unless there is a special interaction with the MultiIndex-related Issues listed in the test ( # GH7724, GH2646), it is a bit of a redundant test. If I missed it, I'll put it back in. |
Greetings!
This PR addresses the tracker at Issue #63207 for DataFrame.drop()
It adds a deprecation warning (Pandas4Warning) for DataFrame.drop(), a deprecation note in docstring, a test for the warning, edits to other affected test files, and whatsnew update.
Adding this warning to DataFrame.drop affected quite a few tests (about 1000 initially failed), so I did 3 things:
I ran pytest pandas -n 4 -m "not slow and not network and not db and not single_cpu" -r sxX.
The result are the same 7 failures I also get when running that same command on my local main branch (no diffs to upstream).