Nishranth Saravanan - 10 months ago 65

Python Question

I want to take a part of values (say 500 values) of an array and perform some operation on it such as take sum of squares of those 500 values. and then proceed with the next 500 values of the same array.

How should I implement this? Would a blackman window be useful in this case or is another approach more suitable?

Answer Source

Assuming your array a is 1D and its length is a multiple a 500, a simple `np.sum(a.reshape((-1, 500)) ** 2, axis=1)`

would suffice. If you want a more complicated operation, please edit your question accordingly.