Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

numpy array majority and how many

import numpy as np
  
  
x = np.array([1, 1, 1, 2, 3, 4, 2, 4, 3, 3, ])
print("Original array:")
print(x)
  
print("Most frequent value in above array")
y = np.bincount(x)
maximum = max(y)
  
for i in range(len(y)):
    if y[i] == maximum:
        print(i, end=" ")
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #numpy #array #majority
ADD COMMENT
Topic
Name
5+7 =