In [1]: import pandas as pd
In [2]: s = pd.Series([3,4,0,3]).sort()
In [3]: s
Indeed In [3]
will output nothing, as you can check:
In [4]: type(s)
Out[4]: NoneType
The reason:
pd.Series([3,4,0,3])
indeed return a pandas Series
type object, BUT Series.sort()
method return nothing because of inplace sorting. So the expression s = pd.Series([3,4,0,3]).sort()
, s
in LHS get nothing from RHS, thus In [3]: s
output nothing.
NOTE that:
After version 0.17.0, sorting by value methods pandas.Series.sort()
and pandas.Series.order()
are DEPRECATED, replaced by a unified pandas.Series.sort_values()
API. See this answer for more details.