Reputation: 43531
My array looks like: (212960,)
I want to split that up into 625
bins of equal length. Since 212960 / 625 isn't an integer, I don't really care about the remaining pieces.
For each bin, I want to fill it with whatever the max value is.
I feel like there's a .reshape
needed, just not sure how to do it.
Upvotes: 1
Views: 276
Reputation: 150745
Here's what I would do (and yes, with reshape
):
# sample data
a = np.arange(212960)
bins = 625
max_size = (len(a)//bins) * bins
new_arr = a[:max_size].reshape(bins, -1).max(1)
Upvotes: 1