Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.30 KB | None | 0 0
  1. df:
  2. col1 col2
  3. 1 10
  4. 1 20
  5. 2 11
  6. 3 33
  7. 1 20
  8. 1 10
  9. 2 24
  10. 3 21
  11. 3 28
  12.  
  13. df
  14. col1 col2
  15. 1 20
  16. 2 11
  17. 3 33
  18. 1 10
  19. 2 24
  20. 3 28
  21.  
  22. df['b_new'] = df.groupby('col1')['col2'].transform('last')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement