python-numpyHow to build histogram for 2-dimensional array
import numpy as np
x = np.array([5,6,6])
y = np.array([1,2,2])
hres = np.histogram2d(x, y, 3)ctrl + c| import numpy as npload Numpy module for Python | np.arraydeclare Numpy array | 
| .histogram2dbuild 2-dimensional histogram | x, yfirst and second dimension | 
| 3number of bins to automatically create | hreswill contain calculated histogram as a list of  | 
Usage example
import numpy as np
x = np.array([5,6,6])
y = np.array([1,2,2])
hres = np.histogram2d(x, y, 3)
print(hres)
output
(array([[1., 0., 0.],
       [0., 0., 0.],
       [0., 0., 2.]]), array([5.        , 5.33333333, 5.66666667, 6.        ]), array([1.        , 1.33333333, 1.66666667, 2.        ]))
Related
More of Python Numpy
- How to save Numpy array to CSV
- Import image data to Numpy array
- How to sort Numpy array descending
- How to use where() to filter array
- How to split Numpy array by chunk length
- How to reshape Numpy array
- How to join 2 Numpy arrays
- How to concatenate Numpy arrays
- Simple Numpy usage example
- Load Numpy array data from JSON
See more codes...