About the numpy, of python, I would like to ask you how to count the two-dimensional numpy.array array and the number of occurrences of each element.

how to solve this problem, ask for advice

Aug.27,2021

In [1]: import numpy as np

In [2]: from collections import Counter

In [3]: a = np.array([[1,2],[3,4]])

In [4]: Counter(a.flatten())
Out[4]: Counter({1: 1, 2: 1, 3: 1, 4: 1})

In [5]: b = np.array([[1,1],[3,4]])
In [6]: Counter(b.flatten())
Out[6]: Counter({1:2, 3: 1, 4: 1})

bincount

python3

>>> a=np.random.randint(1,10,15).reshape(3,5)/10
>>> a
array([[ 0.6,  0.8,  0.3,  0.5,  0.7],
       [ 0.7,  0.6,  0.7,  0.4,  0.4],
       [ 0.1,  0.8,  0.4,  0.5,  0.5]])
>>> , = np.unique(a, return_counts=True)
>>> np.vstack((, ))
array([[ 0.1,  0.3,  0.4,  0.5,  0.6,  0.7,  0.8],
       [ 1. ,  1. ,  3. ,  3. ,  2. ,  3. ,  2. ]])
>>> 
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e512dd-45111.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e512dd-45111.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?