Is this an efficient way to compute a moving average?
<p>I've some <code>{open|high|low|close}</code> market data. I want to compute a Simple Moving Average from the <code>close</code> value of each row.</p>

<p>I've had a look around and couldn't find a simple way to do this. I've computed it via the below method. I want to know if there is a better way:</p>

<pre><code>data = get_data_period_symbol('1h', 'EURUSD')

empty_list = np.zeros(len(data))

data['SMA10'] = empty_list
ma = 10

for i in range(ma-1, len(data)):
    vals = data['&lt;CLOSE&gt;'][i-(ma-1):i+1].tolist()
    mean = np.average(vals)
    index = data.index[i]
    data.set_value(index, 'SMA10', mean)
</code></pre>

<pre><code>data['SMA10'] = pd.rolling_mean(data['&lt;CLOSE&gt;'][:], 10)
</code></pre>

<p>Was my original found solution, however you get a warning saying it's deprecated</p>

<p>Therefore:</p>

<pre><code>data['SMA10'] = data['&lt;CLOSE&gt;'][:].rolling(window=10, center=False).mean()
</code></pre>

python pandas dataframe moving-average