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 pandas.io.data as web


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

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']
sp500['42-252'].tail()
sp500['42-252'].head()


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
(Pdb) 

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

Thanks, all.
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to