for ma in ma_day:
column_name = "MA for %s days" %(str(ma))
AAPL[column_name] = pd.rolling_mean(AAPL['Adj Close'],ma)
I'm getting this error:
'module' object has no attribute 'rolling_mean'
I am working with python2
for ma in ma_day:
column_name = "MA for %s days" %(str(ma))
AAPL[column_name] = pd.rolling_mean(AAPL['Adj Close'],ma)
I'm getting this error:
'module' object has no attribute 'rolling_mean'
I am working with python2
pandas.rolling_mean
is deprecated now, there's no such method, which gives an error (also, look here). There's no such method in actual pandas distributions. Instead you can use a combination of rolling
and mean
methods:
for ma in ma_day:
column_name = "MA for %s days" %(str(ma))
AAPL[column_name] = AAPL['Adj Close'].rolling(window=ma).mean()
Also you can install and use pandas versions ≤ 0.17
, but it's deprecated and highly discouraged.