Reputation: 21
I have a numpy array with timestamps in seconds
For example, this array named a
:
a = np.array(10,95,99,100,250)
Then I have an array b
which gives me the amount of shares that come in corresponding to the timestamps in a:
b = np.array(1,2,3,4,5)
I want to find the number of shares that come in every minute, is there a quick way of doing this without iterating through the whole array?
e.g.:
result = [1,9,0,5]
Upvotes: 1
Views: 60
Reputation:
These's indeed a quick and painless way to do this:
bins = np.arange(10, 250+1, 60)
result, _ = np.histogram(a, bins, weights=b)
Upvotes: 2