0

Given an array such that:

arr = np.array([0,0,1,1,1,2,2,3,3,3,3,3,4,4,5,5,5,5,5,6])

I want to know the frequency of values >=0 & <1, >=1 & <2, >=2 & <3...etc

so I would get an new array like:

freq =[2,3,2,5,2,5,1].

I can use np.where((arr>=0)&(arr<1)) but this changes the shape of arr. Is there a pythonic way of getting the frequency of values over an interval of 1?

Nathan Thomas
  • 1,508
  • 7
  • 25
  • 51

0 Answers0