在Pandas编码中找到“不能用多维密钥索引”

时间:2015-10-26 01:10:48

标签: python pandas

运行以下代码,在倒数第二行找到错误:

  

“buy_index = index_data [index_data ['Close']>   index_data [ 'N1H']。移位(1)]“

     

读取“ValueError:无法使用多维密钥进行索引。”

任何建议将不胜感激。提前谢谢。

import pandas.io.data as web
import pandas as pd
symbol_list=['USB', 'AMGN','GS','BIIB', 'AGN']
N1 = 20
STOCK4 = web.DataReader(name= symbol_list,data_source='yahoo',start='2010-1-1')
index_data = STOCK4[['High','Low','Close']]
index_data['N1H']=pd.rolling_max(index_data['High'],N1)
index_data['N1H'].fillna(value=pd.expanding_max(index_data['High']), inplace=True)
buy_index=index_data[index_data['Close'] > index_data['N1H'].shift(1)]  ## an error
index_data.loc['buy_index'] = 1

0 个答案:

没有答案