python equivalent of R table

前端 未结 7 1740
没有蜡笔的小新
没有蜡笔的小新 2021-01-30 19:27

I have a list

[[12, 6], [12, 0], [0, 6], [12, 0], [12, 0], [6, 0], [12, 6], [0, 6], [12, 0], [0, 6], [0, 6], [12, 0], [0, 6], [6, 0], [6, 0], [12, 0], [6, 0], [         


        
7条回答
  •  不知归路
    2021-01-30 20:02

    Pandas has a built-in function called value_counts().

    Example: if your DataFrame has a column with values as 0's and 1's, and you want to count the total frequencies for each of them, then simply use this:

    df.colName.value_counts()
    

提交回复
热议问题