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.

reset_indexbool, optional (default: True)

If True, the index is reset to a sequential range index. If False, the original index is maintained.

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
0  0  6
1  1  1
2  2  3
3  2  4
4  4  5
5  5  2
>>> df >> arrange('x', '-y')
   x  y
0  0  6
1  1  1
2  2  4
3  2  3
4  4  5
5  5  2
>>> df >> arrange('np.sin(y)')
   x  y
0  4  5
1  2  4
2  0  6
3  2  3
4  1  1
5  5  2