Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- df = pd.DataFrame({'C': [20, 20, 20, 20, 10, 10, 10, 30, 30, 30],
- 'C2': [20, 20, 20, 20, 10, 10, 10, 30, 30, 30],
- 'D': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]})
- df_dictionary = df.groupby(["C", "C2"])
- second_dict = dict()
- for key, df_values in df_dictionary:
- print(len(df_values.index))
- for key[0], df_values in df_dictionary.iteritems():
- second_dict.setdefault(key, []).extend(df_values.index)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement