API/DEPR: Deprecate inplace parameter
See original GitHub issueThe parameter inplace=False
should be deprecated across the board in preparation for pandas
2, which will not support that input (we will always return a copy). That would give people time to stop using it.
Thoughts?
Methods using inplace
:
Deprecation non controvertial (a copy will be made anyway, and inplace=True
does not add value):
- (Series/DataFrame).drop
- (Series/DataFrame).drop_duplicates
- (Series/DataFrame).dropna
- DataFrame.set_index (with
drop=False
wouldn’t change the data, but that doesn’t seem the main use case) - DataFrame.query
- DataFrame.eval
Not sure:
- (Series/DataFrame).sort_values
- (Series/DataFrame).sort_index
Should be able to not copy memory (under discussion on what to do):
- (Series/DataFrame).clip
- (Series/DataFrame).where
- (Series/DataFrame).fillna
- (Series/DataFrame).rename_axis
- (Series/DataFrame).reset_index
- (Series/DataFrame).replace
- (Series/DataFrame).set_axis
- (Series/DataFrame).mask
- (Series/DataFrame).interpolate
- DataFrame.rename
- Index.rename
- Index.set_names
- MultiIndex.set_levels
- MultiIndex.set_labels
- pandas.core.resample.Resampler.interpolate
Special cases:
- pandas.eval (with
inplace=False
the value is not returned but set to an argumenttarget
)
Issue Analytics
- State:
- Created 6 years ago
- Reactions:41
- Comments:52 (42 by maintainers)
Top Results From Across the Web
In pandas, is inplace = True considered harmful, or not?
Yes, it is. Not just harmful. Quite harmful. This GitHub issue is proposing the inplace argument be deprecated api-wide sometime in the near...
Read more >Deprecated API Migration Guide - Kubernetes
This page contains information you need to know when migrating from deprecated API versions to newer and more stable API versions. Removed APIs...
Read more >Why You Should Probably Never Use pandas inplace=True
The parameter will likely eventually be deprecated (so you may as well get used to not using it already). In conclusion, inplace=True is...
Read more >Deprecations by version - GitLab Docs
The support for registration tokens and certain runner configuration arguments in the POST method operation on the /api/v4/runners endpoint is deprecated.
Read more >What's the future of the pandas library? - Data School
The pandas core team discourages the use of the inplace parameter, and eventually it will be deprecated (which means "scheduled for removal from ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
this is too complex. You either do it inplace or you don’t. The keyword controls it. If we remove the keyword then it should never modify the original.
@jreback I understand that there needs to be specific conditions for
inplace
to actually work. I’ve profiled myupdate()
call, and it’s definitely halving memory compared to a standardjoin()
, presumably because my dataframe’s dytpes are all floats. My point was that this (dataframe of a single dtype) is an extremely common case in data science work, which I believe is one of Pandas main use-cases. By removing explicit and/or inherentinplace
calls, you’re removing my ability to do memory optimisation which halve my peak RAM use. When you’re working with 50Gb+ dataframes, this is a big deal.@toobaz yep - there was some discussion above of whether the existing few inherently inplace operations should remain. I was giving an example where they are very useful to have, but also trying to make a case that other inplace operations are still extremely useful. For example, it seems crazy to me to remove an optimisation for, say fillna(), which halves the overall peak memory usage.
Now I don’t understand the complexity of keeping the
inplace
param and functions, but if you could keep them, and instead educate users about when they don’t work (using a warning message for mixed dtype dataframes, for example), I would find this far more useful.