Flatten a list of elements in Pandas DataFrame
Use explode
:
df = df.explode('subGroups')
You can fix your output by following :
pd.DataFrame({'name':df.name.repeat(df.subGroups.str.len()),'subGroup':df.subGroups.sum()})
Out[364]:
name subGroup
0 groupA 123
0 groupA 456
1 groupB aaa
1 groupB bbb
1 groupB ccc