numpy-100
numpy-100 copied to clipboard
Q83 doesn't directly work for floats or sparse integers
83. How to find the most frequent value in an array?
answer(83)
# Z = np.random.randint(0,10,50)
# print(np.bincount(Z).argmax())
If the array is made out of floats, this doesn't work. If the array is sparse but wide (e.g. [1e9,2e9,2e9]), then this is not efficient as well.
Most frequent value with floats doesn't make really sense unless you use an alsmost_equal function with a given epsilon. As for efficiency, this is not the goal here.