0

I am trying to extract data from column, but it is keep saying there is an another exception.

any help will be appreciated

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"]

but it says

KeyError: 'Player Name'

During handling of the above exception, another exception occurred:
xbello
  • 6,834
  • 3
  • 26
  • 39

1 Answers1

0

Pandas doesn't like spaces in column names. Look this answer:

https://stackoverflow.com/a/30514678/1688590

xbello
  • 6,834
  • 3
  • 26
  • 39
  • If you think it is already answered in another question, can you please mark it as duplicate? – arsho Aug 24 '19 at 06:03
  • I had already marked it as duplicate before you commented, but being Tatsuya a new contributor it may feel rude to just "answer" with a flag. – xbello Aug 26 '19 at 16:35