I am trying to sort a dataframe by total column:
df.sort_values(by='Total', ascending=False, axis=0, inplace=True)
But I'm getting the following warning:
/usr/local/lib/python3.6/dist-packages/ipykernel_launcher.py:1: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame
See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
"""Entry point for launching an IPython kernel.
When I followed the link it opens up and using .loc
methods is suggested. But after that I followed the .sort_values() where I find out to use inplace=False
or None.
My question is what if I got a dataframe columns which is not sorted, and if I don't use inplace=True
, my dataframe will be sorted for further use or I have to assigned a new name to the dataframe and saved it.