bincount
顾名思义 bin的count
bin出现在哪里呢?
hist() 的参数bins是不是很熟悉
实现的功能类似直方图,即number和frequency的关系
对应hist()参数bins=max(序列最大值)+1
即划分计数区间为[0,1),[1,2),...,[max(序列最大值),max(序列最大值)+1)
实操如下:
lst=[11,11,11,2,10,10]
np.bincount(lst)
输出:
array([0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 2, 3], dtype=int64)
对应hist()bins参数为11+1=12
plt.hist(lst,bins=12)
输出:
就是说,即0到序列最大值每个数的个数.
下面介绍
value_count
统计每个数的个数并默认降序排列
se=pd.Series([2,3,3,3,6,6])
pd.value_counts(se,ascending=False)
输出:
原文:https://www.cnblogs.com/LangB/p/13081102.html