Skip to content

API/DEPR: Deprecate inplace parameter #16529

Open
@gfyoung

Description

@gfyoung
Member

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 argument target)

Activity

changed the title [-]API/DEPR: Deprecate inplace operations[/-] [+]API/DEPR: Deprecate inplace parameter[/+] on May 29, 2017
modified the milestones: 0.21.0, 1.0 on May 30, 2017
drafter250

drafter250 commented on Jul 26, 2017

@drafter250

I thought The main usage of this feature was to mitigate memory usage in case of large DataFrames?

gfyoung

gfyoung commented on Jul 26, 2017

@gfyoung
MemberAuthor

I thought The main usage of this feature was to mitigate memory usage in case of large DataFrames?

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

jreback commented on Aug 22, 2017

@jreback
Contributor

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

kapoor1992 commented on Mar 18, 2024

@kapoor1992

7 years since this was opened, is this still something we want to do?

phofl

phofl commented on Mar 19, 2024

@phofl
Member

This is actually covered by PDEP8, I guess we can close here

added a commit that references this issue on Jul 18, 2024
added a commit that references this issue on Jan 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    API DesignClosing CandidateMay be closeable, needs more eyeballsDeprecateFunctionality to remove in pandasNeeds DiscussionRequires discussion from core team before further actioninplaceRelating to inplace parameter or equivalent

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @jondo@tommedema@jreback@jorisvandenbossche@toobaz

      Issue actions

        API/DEPR: Deprecate inplace parameter · Issue #16529 · pandas-dev/pandas