这里给出一种方法,首先,将该列转化为list
list1 = df3["Alarm_Z"].values.tolist()
然后利用numpy统计
dict(zip(*np.unique(lst, return_counts=True)))
不推荐使用collections统计或者list.count来统计,因为可能会遇到TypeError: unhashable type: 'list’错误。
此外也不推荐使用df3[“Alarm_Z”].value_counts()来统计,因为版本原因,有些版本的pandas好像没有这个方法。