Suppose I have the following NumPy array:
a = np.array([1,2,3,1,2,1,1,1,3,2,2,1])
How can I find the less frequent number in this array?
Use collections.Counter-
collections.Counter
from collections import Counter a = Counter([1,2,3,1,2,1,1,1,3,2,2,1]) print(a.most_common()[-1][0])
1.4m articles
1.4m replys
5 comments
57.0k users