SyntaxFix
Write A Post
Hire A Developer
Questions
If you want to use numpy only:
x = [-1, 2, 1, 3, 3] vals,counts = np.unique(x, return_counts=True)
gives
(array([-1, 1, 2, 3]), array([1, 1, 1, 2]))
And extract it:
index = np.argmax(counts) return vals[index]