Error: valueError: ordinal must be >= 1

ryguy7272 ryanshuell at
Tue Jul 28 01:13:29 CEST 2015

Hello experts.  I'm working in Python > Anaconda > Spyder.

I'm reading a book called 'Python for Finance' and I'm trying to run this sample code:

import numpy as np
import pandas as pd
import as web

sp500 = web.DataReader('^GSPC', data_source='yahoo', start='1/1/2000', end='4/14/2014')

sp500['Close'].plot(grid=True, figsize=(8, 5))

sp500['42d'] = np.round(pd.rolling_mean(sp500['Close'], window=42), 2)
sp500['252d'] = np.round(pd.rolling_mean(sp500['Close'], window=252), 2)

sp500[['Close', '42d', '252d']].tail()

sp500[['Close', '42d', '252d']].plot(grid=True, figsize=(8, 5))

sp500['42-252'] = sp500['42d'] - sp500['252d']

It seems to work perfectly find when I see the results in the book, but all I'm getting is this . . . 
*** ValueError: ordinal must be >= 1

Does anyone have any idea what I'm doing wrong?

Thanks, all.

More information about the Python-list mailing list