Count of elements in lists within pandas data frame

后端 未结 3 1078
你的背包
你的背包 2021-02-04 05:13

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         


        
3条回答
  •  攒了一身酷
    2021-02-04 05:51

    You can also have an one liner like this:

    df = pd.Series(sum([item for item in din.x], [])).value_counts()
    

提交回复
热议问题