Guest User

Untitled

a guest
Oct 18th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  1. ID, ATTRIBUTE
  2. 1, thing2
  3. 1, thing3
  4. 1, thing3
  5. 2, thing7
  6. 2, thing7
  7. 2, thing2
  8. 3, thing1
  9. 3, thing2
  10.  
  11. mode = lambda x: x.mode() if len(x) > 2 else 'multithing'
  12. df_grouped = df.groupby(['ID'], as_index=False)['ATTRIBUTE].agg(mode)
  13.  
  14. ID, ATTRIBUTE
  15. 1, thing3
  16. 2, thing7
  17. 3, multithing
  18.  
  19. df_final.groupby('ATTRIBUTE')['ID'].count()
Add Comment
Please, Sign In to add comment