I am doing a time series analysis of Microsoft stock with data pulled from Quandl. I want to plot closing prices against moving averages. When I plot the moving averages they do not go all the way to right side of the graph. 

I believe having a gap makes sense (for instance the 200 day moving average can't start until day 200), but am concerned that the gap is on the right. This implies that it is starting on the most recent date (which makes some sense as most recent date is first in the time series), which is obviously not the correct way to do it.

I could just reverse the series (new data frame ascending instead of descending), but I believe it would then also plot the graph starting at the most recent date, which is obviously not acceptable.

```
#calculate moving averages for Microsoft

roll100 = MSFT_data['Adj. Close'].rolling(100).mean()
roll200 = MSFT_data['Adj. Close'].rolling(200).mean()
roll50 = MSFT_data['Adj. Close'].rolling(50).mean()
roll10 = MSFT_data['Adj. Close'].rolling(10).mean()

roll200.plot(label = '200 Day Moving Average')
roll50.plot(label = '50 Day Moving Average')
roll100.plot(label = '100 Day Moving Average')
MSFT_data['Adj. Close'].plot(label = 'MSFT Closing Price', color = 'blue')
plt.legend(loc = 'upper left')

```

Since moving averages should always be calculated starting with the earliest date, I'm assuming I'm missing a simple command to do so.

Update: it was suggested that I make the moving averages part of the original data frame (I assume so they were associated with the date index) but I had the same result:

```

MSFT_data['roll100'] = MSFT_data['Adj. Close'].rolling(100).mean()
MSFT_data['roll200'] = MSFT_data['Adj. Close'].rolling(200).mean()
MSFT_data['roll50'] = MSFT_data['Adj. Close'].rolling(50).mean()
MSFT_data['roll10'] = MSFT_data['Adj. Close'].rolling(10).mean()

#plot Microsoft Price along with moving averages

fig = plt.figure()
fig.set_figheight(8)
fig.set_figwidth(10)

MSFT_data['roll200'].plot(label = '200 Day Moving Average')
MSFT_data['roll50'].plot(label = '50 Day Moving Average')
MSFT_data['roll100'].plot(label = '100 Day Moving Average')
MSFT_data['Adj. Close'].plot(label = 'MSFT Closing Price', color = 'blue')
plt.legend(loc = 'upper left')

```

[![Graph](https://i.stack.imgur.com/v6zyP.png)](https://i.stack.imgur.com/v6zyP.png)

Also if I examine the column for instance with:

```py
MSFT_data['roll10'].head(12)

Date
2017-12-29       NaN
2017-12-28       NaN
2017-12-27       NaN
2017-12-26       NaN
2017-12-22       NaN
2017-12-21       NaN
2017-12-20       NaN
2017-12-19       NaN
2017-12-18       NaN
2017-12-15    85.796
2017-12-14    85.711
2017-12-13    85.674
Name: roll10, dtype: float64

```

I can see that the 9 most recent values are NaN. Conversely if I create a new data frame and try to reindex ascending, my last 9 values in the tail are NaN.