Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pandas as pd
- import numpy as np
- df = pd.DataFrame({'id': np.array([1,1,2,3,3,3]),
- 'no': np.array([1,2,3,0,1,2]),
- 'col1': np.random.randn(6),
- 'col2': np.random.randn(6)})
- df = df.sort_values(['id', 'no'], ascending=[1, 0])
- df.groupby('id').first()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement