I need to get the frequency of each element in a list when the list is in a pandas data frame columns
In data:
din=pd.DataFrame({'x':[['a','b','c'],['a','e','d', 'c']]})`
x
0 [a, b, c]
1 [a, e, d, c]
Desired Output:
f x
0 2 a
1 1 b
2 2 c
3 1 d
4 1 e
I can expand the list into rows and then perform a group by but this data could be large ( million plus records ) and was wondering if there is a more efficient/direct way.
Thanks
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…