SHARE
TWEET

Untitled

a guest Jun 19th, 2019 52 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. df = pd.DataFrame({'C': [20, 20, 20, 20, 10, 10, 10, 30, 30, 30],
  2.                    'C2': [20, 20, 20, 20, 10, 10, 10, 30, 30, 30],
  3.                    'D': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]})
  4.  
  5. df_dictionary = df.groupby(["C", "C2"])
  6.  
  7. second_dict = dict()
  8.  
  9. for key, df_values in df_dictionary:
  10.     print(len(df_values.index))
  11.      
  12. for key[0], df_values in df_dictionary.iteritems():
  13.     second_dict.setdefault(key, []).extend(df_values.index)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top