def itemfreq(a):
 (items, inv) = np.unique(a, return_inverse=True)
 freq = np.bincount(inv)
 return np.array([items, freq]).T

def itemfreq ( a ) : ( items , inv ) = np . unique ( a , return_inverse = True ) freq = np . bincount ( inv ) return np . array ( [ items , freq ] ) . T
returns a 2-d array of item frequencies .