Skip to content

Instantly share code, notes, and snippets.

@lmeulen
Last active August 23, 2022 20:13
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/d85c2384cbe63b4721fffaee246b8e69 to your computer and use it in GitHub Desktop.
Save lmeulen/d85c2384cbe63b4721fffaee246b8e69 to your computer and use it in GitHub Desktop.
ergast_places_gained
year = 2022
rnd = 13
pgl = stats.get_race_results(year)
pgl = pgl[pgl['round'] == rnd][['driver', 'grid', 'position']]
pgl['change'] = pgl['grid'] - pgl['position']
def _color_red_or_green(val):
color = 'orangered' if val < 0 else 'springgreen'
return 'background-color: %s' % color
pgl.style.applymap(_color_red_or_green, subset=['change'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment