Skip to content

Latest commit

 

History

History
28 lines (17 loc) · 848 Bytes

File metadata and controls

28 lines (17 loc) · 848 Bytes

Most pandas operations return copies of the Series/DataFrame. To make the changes "stick", you'll need to either assign to a new variable:

sorted_df = df.sort_values("col1")

or overwrite the original one:

df = df.sort_values("col1")

Note

You will see an inplace=True or copy=False keyword argument available for some methods:

df.replace(5, inplace=True)

There is an active discussion about deprecating and removing inplace and copy for most methods (e.g. dropna) except for a very small subset of methods (including replace). Both keywords won't be necessary anymore in the context of Copy-on-Write. The proposal can be found [here](pandas-dev#51466).