當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Python Scipy stats.itemfreq()用法及代碼示例

scipy.stats.itemfreq(arr, axis = None) 函數可以幫助我們計算項目頻率。

參數:
arr :[數組]輸入數組。

結果:具有物品頻率的2D陣列。


代碼1:用於variation()

# cummulative 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]


相關用法


注:本文由純淨天空篩選整理自vishal3096大神的英文原創作品 sciPy stats.itemfreq() function | Python。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。