Guest User

Untitled

a guest
Jul 21st, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. d = {1:0, 2:0, 3:1, 4:0, 5:2, 6:1, 7:2, 8:0}
  2.  
  3. pandas_ordered = { 0:[1,2,4,8], 1:[3,6], 2:[5,7] }
  4.  
  5. pd.Series(list(d.values())).groupby(list(partition.keys())).to_dict()
  6.  
  7. # Example:
  8. import pandas as pd
  9.  
  10. d = {1:0, 2:0, 3:1, 4:0, 5:2, 6:1, 7:2, 8:0}
  11.  
  12.  
  13. def pandas_groupby(dictionary):
  14. values = list(dictionary.values())
  15. keys = list(dictionary.keys())
  16. return pd.Series(values).groupby(keys).to_dict()
  17.  
  18.  
  19. pandas_groupby(d)
Add Comment
Please, Sign In to add comment