I have a dataframe with many columns representing football match stats.
Since I’ve scraped the data, I have two rows per match and I’m trying to remove duplicates.
I tried executing:
df.drop(all_matches[df['HomeTeam'] != df['team']])
to remove instances where values in the HomeTeam columns don’t match the team columns.
I got the following error:
KeyError: “[‘date’ ‘time’ ‘comp’ ’round’ ‘day’ ‘venue’ ‘result’
‘HomeTeam’ ‘AwayTeam’n ‘gf’ ‘ga’ ‘opponent’ ‘poss’ ‘attendance’
‘captain’ ‘formation’ ‘referee’n ‘match report’ ‘notes’ ‘sh’ ‘sot’
‘pk’ ‘pkatt’ ‘venue_vs’ ‘result_vs’n ‘team_shots_vs’
‘team_shots_ot_vs’ ‘pk_vs’ ‘pkatt_vs’ ‘season’ ‘team’] not found in
axis”
I don’t understand why it isn’t working and why some column names are followed by a new line character after the quotes