DataFrame.copy(deep=True)[source]
Make a copy of this object’s indices and data.
When deep=True (default)
, a new object will be created with a copy of the calling object’s data and indices. Modifications to the data or indices of the copy will not be reflected in the original object (see notes below).
When deep=False
, a new object will be created without copying the calling object’s data or index (only references to the data and index are copied). Any changes to the data of the original will be reflected in the shallow copy (and vice versa).
If we want to drop some columns while it doesn’t change the original dataframe, we can just leave the df.drop(inplace=False)
as default which will return the new dataframe with the specified columns removed.
references: https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.drop.html
https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.copy.html