bigframes.pandas.Series.sort_index#

Series.sort_index(*,axis=0,inplace:Literal[False]=False,ascending=True,na_position='last')Series[source]#
Series.sort_index(*,axis=0,inplace:Literal[True]=False,ascending=True,na_position='last')None

Sort Series by index labels.

Returns a new Series sorted by label ifinplace argument isFalse, otherwise updates the original series and returns None.

Examples:

>>>s=bpd.Series(['a','b','c','d'],index=[3,2,1,4])>>>s.sort_index()1    c2    b3    a4    ddtype: string

Sort Descending

>>>s.sort_index(ascending=False)4    d3    a2    b1    cdtype: string

By default NaNs are put at the end, but use na_position to place them atthe beginning

>>>s=bpd.Series(['a','b','c','d'],index=[3,2,1,np.nan])>>>s.sort_index(na_position='first')<NA>    d1.0     c2.0     b3.0     adtype: string
Parameters:
  • axis ({0 or'index'}) – Unused. Parameter needed for compatibility with DataFrame.

  • inplace (bool,default False) – Whether to modify the Series rather than creating a new one.

  • ascending (bool orlist-like ofbools,default True) – Sort ascending vs. descending. When the index is a MultiIndex thesort direction can be controlled for each level individually.

  • na_position ({'first','last'},default 'last') – If ‘first’ puts NaNs at the beginning, ‘last’ puts NaNs at the end.Not implemented for MultiIndex.

Returns:

The original Series sorted by the labels or None ifinplace=True.

Return type:

bigframes.pandas.Series or None

On this page

This Page