📜  sciPy stats.itemfreq()函数| Python

📅  最后修改于: 2022-05-13 01:54:30.732000             🧑  作者: Mango

sciPy stats.itemfreq()函数| Python

scipy.stats.itemfreq(arr, axis = None)函数帮助我们计算项目频率。

代码 #1:使用变体()

Python3
# cumulative frequency
from scipy import stats
import numpy as np 
   
arr = [14, 31, 27, 27, 31, 13, 14, 13] 
   
print ("Itemfrequency : \n", stats.itemfreq(arr))
   
print ("\n\nBincount : \n", np.bincount(arr))


输出:
Itemfrequency : 
 [[13  2]
 [14  2]
 [27  2]
 [31  2]]


Bincount : 
 [0 0 0 0 0 0 0 0 0 0 0 0 0 2 2 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 2]