我正在尝试从列中提取数据,但它一直说还有另一个例外。
任何帮助将不胜感激
data = pd.read_csv('2019_data.csv')
data.head()
Player Name Date Statistic Variable Value
0 Cameron Champ 2019-08-18 Driving Distance Driving Distance - (ROUNDS) 78
1 Rory McIlroy 2019-08-18 Driving Distance Driving Distance - (ROUNDS) 68
2 Luke List 2019-08-18 Driving Distance Driving Distance - (ROUNDS) 66
3 Wyndham Clark 2019-08-18 Driving Distance Driving Distance - (ROUNDS) 87
4 Dustin Johnson 2019-08-18 Driving Distance Driving Distance - (ROUNDS) 69
df = data.groupby(['Player Name']).first()
ds = df.sort_values(by = ["Value"])
ds["Player Name"]
但它说
KeyError: 'Player Name'
During handling of the above exception, another exception occurred:
> Pandas 不喜欢列名中的空格。看看这个答案:
https://stackoverflow.com/a/30514678/1688590