Wednesday, July 3, 2024
HomeLanguagesPythonsciPy stats.itemfreq() function | Python

sciPy stats.itemfreq() function | Python

scipy.stats.itemfreq(arr, axis = None) function helps us to calculate the item frequencies. 

Parameters : 
arr : [array_like] input array. 
Results : 2D array with item frequency. 

Code #1: Use of variation()  

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))


Output: 

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]

 

Nango Kalahttps://www.kala.co.za
Experienced Support Engineer with a demonstrated history of working in the information technology and services industry. Skilled in Microsoft Excel, Customer Service, Microsoft Word, Technical Support, and Microsoft Office. Strong information technology professional with a Microsoft Certificate Solutions Expert (Privet Cloud) focused in Information Technology from Broadband Collage Of Technology.
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments