Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- df:
- col1 col2
- 1 10
- 1 20
- 2 11
- 3 33
- 1 20
- 1 10
- 2 24
- 3 21
- 3 28
- df
- col1 col2
- 1 20
- 2 11
- 3 33
- 1 10
- 2 24
- 3 28
- df['b_new'] = df.groupby('col1')['col2'].transform('last')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement