Using Pandas documentation
http://pandas.pydata.org/pandas-docs/version/0.13.1/generated/pandas.DataFrame.pct_change.html
I am trying to create this function to calculate percentage_change . I pass two paramters to it
def PCT(df,n):
d = df['Close'].pct_change(n)
Even rewriting the same code in different way give me same error
P = pd.Series(df['Close'].pct_change(n), name = 'PCT_' + str(n))
- dataframe
- window over which I want % change
It throwing error
File "D:\Python Scripts\TA_Liabrary.py", line 15, in PCT
d = df['Close'].pct_change(n)
TypeError: 'NoneType' object has no attribute '__getitem__'
Can someone please help me in this
Sample data
Index open high low close volume adj.
1/01/2014 54.97 54.97 54.97 54.97 0 49.31993
2/01/2014 55.1 55.95 54.86 55.08 216100 49.41862
3/01/2014 54.5 55 54.16 55 392600 49.34685
6/01/2014 54.82 55.47 54.62 55.14 344500 49.47245
7/01/2014 55.06 55.17 54.27 54.35 677400 48.76365
8/01/2014 54.64 54.88 53.87 54.38 587500 48.79057
9/01/2014 54.57 54.8 54.05 54.48 466800 48.88029