Open
Description
The 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
)
Activity
[-]API/DEPR: Deprecate inplace operations[/-][+]API/DEPR: Deprecate inplace parameter[/+]drafter250 commentedon Jul 26, 2017
I thought The main usage of this feature was to mitigate memory usage in case of large DataFrames?
gfyoung commentedon Jul 26, 2017
I think @jreback might know more about the initial usage, but generally from previous discussion, this parameter is misused and is more prone to introducing bugs.
jreback commentedon Aug 22, 2017
inplace does not generally do anything inplace
but makes a copy and reassigns the pointer
mutating code is much harder to debug (not to mentiin more complicated to support actual inplace ops)
so except for inplace indexing generally these operations are simply more verbose and serve just to provide corner cases for testing
119 remaining items
kapoor1992 commentedon Mar 18, 2024
7 years since this was opened, is this still something we want to do?
phofl commentedon Mar 19, 2024
This is actually covered by PDEP8, I guess we can close here
TST: Resolve pandas warnings emitted during tests
TST: Resolve pandas warnings emitted during tests
TST: Resolve pandas warnings emitted during tests
fix deprecation warning from pandas
Don't copy dataframes or use inplace=True (#305)