Numpy : Calculating the average of values between two indices
<p>I need to calculate the average of values that are between 2 indices. Lets say my indices are 3 and 10, and i would like to sum up all the values between them and divide by the number of values.</p>

<p>Easiest way would be just using a for loop starting from 3, going until 10, summing 'em up, and dividing. This seems like a really non-pythonic way and considering the functionalities Numpy offers, i thought maybe there is a shorter way using some Numpy magic. Any suggestion is much appriciated</p>

<pre><code>import numpy as np

np.mean(yourarray[3:11])
</code></pre>

<p>Assumed your array name is "yourarray" </p>

python python-3.x numpy