Series.
sort_index
Sort object by labels (along an axis)
if not None, sort on values in specified index level(s)
Sort ascending vs. descending
if True, perform operation in-place
pandas-on-Spark does not allow specifying the sorting algorithm at the moment, default None
first puts NaNs at the beginning, last puts NaNs at the end. Not implemented for MultiIndex.
Examples
>>> df = ps.Series([2, 1, np.nan], index=['b', 'a', np.nan])
>>> df.sort_index() a 1.0 b 2.0 NaN NaN dtype: float64
>>> df.sort_index(ascending=False) b 2.0 a 1.0 NaN NaN dtype: float64
>>> df.sort_index(na_position='first') NaN NaN a 1.0 b 2.0 dtype: float64
>>> df.sort_index(inplace=True) >>> df a 1.0 b 2.0 NaN NaN dtype: float64
>>> df = ps.Series(range(4), index=[['b', 'b', 'a', 'a'], [1, 0, 1, 0]], name='0')
>>> df.sort_index() a 0 3 1 2 b 0 1 1 0 Name: 0, dtype: int64
>>> df.sort_index(level=1) a 0 3 b 0 1 a 1 2 b 1 0 Name: 0, dtype: int64
>>> df.sort_index(level=[1, 0]) a 0 3 b 0 1 a 1 2 b 1 0 Name: 0, dtype: int64