1import pandas as pd
2df = pd.DataFrame({'A': ['one', 'one', 'two', 'three', 'three', 'one'], 'B': range(6)})
3print(df)
4# A B
5#0 one 0
6#1 one 1
7#2 two 2
8#3 three 3
9#4 three 4
10#5 one 5
11
12grouped_df = df.groupby('A')
13
14for key, item in grouped_df:
15 print(grouped_df.get_group(key), "\n\n")
16
17# A B
18#A
19#one 0 one 0
20# 1 one 1
21# 5 one 5
22#two 2 two 2
23#three 3 three 3
24# 4 three 4