熊猫keyError:('%s not in index'%objarr [mask])

时间:2019-01-30 11:10:45

标签: machine-learning python pandas dataframe indexing

我是机器学习领域的初学者。我从下面的代码开始:

#import modules
import pandas as pd
import quandl

df = quandl.get('WIKI/GOOGL')

#using required data frames
df = df[['Adj.Open','Adj.High','Adj.Low','Adj.Close','Adj.Volume',]]

#getting percent change in High and Low at closing
df['HL_PCT'] = (df['Adj.High'] - df['Adj.Close']) / df['Adj.Close'] * 100.0

#getting percent change in price
df['PCT_change'] = (df['Adj.Close'] - df['Adj.Open']) / df['Adj.Open'] * 100.0

df = df[['Adj.Close','HL_PCT','PCT_change','Adj.Volume']]

print(df.head())

但是我收到索引错误:

raise KeyError('%s not in index' % objarr[mask])

KeyError: "['Adj.Open' 'Adj.High' 'Adj.Low' 'Adj.Close' 'Adj.Volume'] not in index"

该如何解决?

0 个答案:

没有答案