rolling mean with increasing window
<p>I have a range</p>

<pre><code>np.arange(1,11) # [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
</code></pre>

<p>and for each element, <em>i</em>, in my range I want to compute the average from element <em>i=0</em> to my current element. the result would be something like:</p>

<pre><code>array([ 1. ,  1.5,  2. ,  2.5,  3. ,  3.5,  4. ,  4.5,  5. ,  5.5])
 # got this result via np.cumsum(np.arange(1,11,dtype=np.float32))/(np.arange(1, 11))
</code></pre>

<p>I was wondering if there isn't an out of the box function in numpy / pandas that gives me this result?</p>

<p>You can use <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.expanding.html" rel="nofollow"><code>expanding()</code></a> (requires pandas 0.18.0):</p>

<pre><code>ser = pd.Series(np.arange(1, 11))

ser.expanding().mean()
Out: 
0    1.0
1    1.5
2    2.0
3    2.5
4    3.0
5    3.5
6    4.0
7    4.5
8    5.0
9    5.5
dtype: float64
</code></pre>

python pandas numpy