<jupyter_start><jupyter_text>boxplotswith Formula 1 data from https://ergast.com/mrd/db<jupyter_code>%autosave 0

from tools import *

plot = Plot()
f1 = ErgastZIP(ERGAST_ZIP)
stops = (
    f1.pit_stops
    .join(f1.races['season id_circuit'.split()], on='id_race')
    .join(f1.circuits['circuit'], on='id_circuit')
    .join(f1.drivers['driver'], on='id_driver')
    ['season circuit driver stop duration'.split()]
    .reset_index(drop=True)
)
stops<jupyter_output><empty_output><jupyter_text>stoppage time<jupyter_code>plot = Plot()

def alltracks(season, **kwargs):
    kwargs.setdefault('title', f"{season} pit stop durations")    
    kwargs.setdefault('xlim', (10, 40))
    kwargs.setdefault('xlabel', 'seconds')
    kwargs.setdefault('flierprops', {'markerfacecolor': '#f1f1f1'})
    
    data = stops.loc[lambda df: df['season'].eq(2019)]
    data = data.pivot(columns='circuit', values='duration')
    
    return plot.boxh(data, **kwargs)

axes = alltracks(2019)
axes.figure.savefig(PLOTDIR / 'stoppage_time.png')<jupyter_output><empty_output><jupyter_text>stowe your roll<jupyter_code>def onetrack(circuit, **kwargs):
    kwargs.setdefault('title', f"{circuit} pit stop duration")
    kwargs.setdefault('ylim', (10, 40))
    kwargs.setdefault('ylabel', 'seconds')
    kwargs.setdefault('flierprops', {'markerfacecolor': '#f1f1f1'})
    
    data = stops.loc[lambda df: df['circuit'].eq(circuit)]
    data = data.pivot(columns='season', values='duration')
    
    return plot.box(data, **kwargs)

axes = onetrack('Silverstone Circuit')
savepng(axes, 'stowe_your_roll')
savepng(onetrack('Yas Marina Circuit'), 'yas_we_can')
savepng(onetrack('Circuit Paul Ricard'), 'paul_ralentit')<jupyter_output>Save /context/data/plots/paul_ralentit.png
{'fraction_non_alphanumeric': 0.16619074814391777, 'fraction_numerical': 0.01656196459166191, 'mean_word_length': 5.586466165413534, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '521086', 'license': 'Apache-2.0', 'n_tokens_mistral': 673, 'n_tokens_neox': 638, 'n_words': 103, 'path': 'books/plot.box.ipynb', 'repo_name': 'samkennerly/brundling', 'size': '1751'}