General and simple answer:
numpy.sum(MyArray==x)
which would lead to this complete code as an example
import numpy MyArray=numpy.array([0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1])
Now, if MyArray is in several dimensions , and you want to calculate the presence of the distribution of values in the row (= template in the future)
MyArray=numpy.array([[6, 1],[4, 5],[0, 7],[5, 1],[2, 5],[1, 2],[3, 2],[0, 2],[2, 5],[5, 1],[3, 0]]) x=numpy.array([5,1])
sol Nov 18 '16 at 16:04 2016-11-18 16:04
source share