Multiple calculations of standard deviation on array subsets by index

Say I have a numpy array: my_array = np.random.rand(100).

and another array of indices: ind_array = ([35, 58, 77])

What would be the fastest way to calculate the standard deviation of the 10 values around each ind_array index in my_array? (i.e. np.std(my_array[30:40]), np.std(my_array[53:63]), np.std(my_array[72:82]) )

It is obviously possible to do using a for-loop, but I'm afraid it will be too slow.

Thanks

1 answer