Skip to content

Instantly share code, notes, and snippets.

@lmeulen
Created August 21, 2022 19:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lmeulen/3abe0f0885ca927daef5476faeefd91d to your computer and use it in GitHub Desktop.
Save lmeulen/3abe0f0885ca927daef5476faeefd91d to your computer and use it in GitHub Desktop.
ergast_field_experience
results = stats.get_race_results()
current_driver_ids = results[results['year'] == 2022]['driverId']
current_drivers = results[results['driverId'].isin(pd.unique(current_driver_ids))]
current_drivers = current_drivers[['driverId', 'driver', 'race']]. \
groupby(['driverId', 'driver']).count().reset_index()
stats.horizontal_barplot(df=current_drivers, rowcount=30, sort_value='race',
sort_ascending=False, invert_yaxis=True,
xcolumn='driver', ycolumn='race',
title='Number of races by drivers in current season',
xlabel = 'races', ylabel='')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment