MulDataFrame.sort_values#

MulDataFrame.sort_values(*args, **kwargs)#

Sort by the values in the values data frame along either axis.

The input parameters are mostly the same as pandas.DataFrame.sort_values method except the return value is a muldataframe.

Parameters#

bystr or list of str

Name or list of names to sort by.

  • if axis is 0 or ‘index’ then by may contain column labels of the values data frame.

  • if axis is 1 or ‘columns’ then by may contain index labels of the values data frame.

Other parameters are exactly the same as those in pandas.DataFrame.sort_values.

Returns#

MulDataFrame

A MulDataFrame object with the values data frame and the index (axis=0) or columns (axis=1) dataframe sorted.

Examples#

>>> index = pd.DataFrame([[1,2],[3,6],[5,6]],
             index=['a','b','b'],
             columns=['x','y'])
>>> columns = pd.DataFrame([[5,7],[3,6]],
            index=['c','d'],
            columns=['f','g'])
>>> mf = MulDataFrame([[1,2],[8,9],[8,7]],index=index,columns=columns)
>>> mf.sort_values('d')
(3, 2)    g  7  6
          f  5  3
             c  d
--------  ---------
   x  y      c  d
a  1  2   a  1  2
b  5  6   b  8  7
b  3  6   b  8  9