Pandas group the rows in a dataframe based on specific column value
You can try this to create a dictionary of data frames with unique groups,
df['Group'] = df.groupby(['gw_mac', 'mac']).cumcount()
dfs = dict(tuple(df.groupby('Group')))
You can access a group using,
dfs[0]
gw_mac mac Group
0 ac233fc015f6 dce83f3bc820 0
1 ac233fc015f6 ac233f264a4c 0
7 ac233fc015f6 e464eecba5eb 0
If need different groups by columns loop by groupby
object:
for i, g in df.groupby(['gw_mac','mac']):
print (g)
gw_mac mac
1 ac233fc015f6 ac233f264a4c
2 ac233fc015f6 ac233f264a4c
4 ac233fc015f6 ac233f264a4c
5 ac233fc015f6 ac233f264a4c
gw_mac mac
0 ac233fc015f6 dce83f3bc820
3 ac233fc015f6 dce83f3bc820
6 ac233fc015f6 dce83f3bc820
gw_mac mac
7 ac233fc015f6 e464eecba5eb