plydata.one_table_verbs.arrange

class plydata.one_table_verbs.arrange(*args, **kwargs)[source]

Sort rows by column variables

Parameters
datadataframe, optional

Useful when not using the >> operator.

argstuple

Columns/expressions to sort by.

Examples

>>> import pandas as pd
>>> import numpy as np
>>> df = pd.DataFrame({'x': [1, 5, 2, 2, 4, 0],
...                    'y': [1, 2, 3, 4, 5, 6]})
>>> df >> arrange('x')
   x  y
5  0  6
0  1  1
2  2  3
3  2  4
4  4  5
1  5  2
>>> df >> arrange('x', '-y')
   x  y
5  0  6
0  1  1
3  2  4
2  2  3
4  4  5
1  5  2
>>> df >> arrange('np.sin(y)')
   x  y
4  4  5
3  2  4
5  0  6
2  2  3
0  1  1
1  5  2