mazoku
6/15/2017 - 8:26 AM

get the most common element in an array.

get the most common element in an array.

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

al = list(a.flatten)

res = max(set(al), key=al.count)