1

While working with pandas I find that some of the methods have inplace=True For example.

df.drop(columns=["first", "last"], inplace=True)

Whereas some methods do not have this argument and we need to explicitly assign the result to a variable.

df = df.append(df2, ignore_index=True)

Is there any specific reason behind this? Can't we just have a uniform way of ensuring that the argument is present for all pandas methods? (as it removes the hassle of assigning it to another variable).

Any help is appreciated. Thank you.

Abercrombie
  • 1,012
  • 2
  • 13
  • 22
  • 1
    Check this answer [Understanding inplace=True](https://stackoverflow.com/a/45856125/11843382) – Hely Andrés Palencia Feb 15 '20 at 15:08
  • 1
    This is something even pandas developers still haven't agreed on. You may [take a look at this thread](https://github.com/pandas-dev/pandas/issues/16529) where it is discussed the usefulness of `inplace` and likely recommendations on deprecation or not of the feature. – rafaelc Feb 15 '20 at 15:23
  • 1
    Also see https://stackoverflow.com/questions/45570984/, spoiler alert: please consider not using the argument – cs95 Feb 15 '20 at 15:53

0 Answers0