F1-analysis / pages /Long_Run_Race_Pace.py
tracinginsights's picture
Update pages/Long_Run_Race_Pace.py
d92ae4d verified
raw
history blame contribute delete
920 Bytes
import streamlit as st
from repo_directory import Long_Run_Race_Pace
from repo_directory import button, utils
import pandas as pd
YEAR_SELECTED = st.selectbox(
'Select Year',
(2024, 2023, 2022, 2021, 2020, 2019, 2018))
RACE_SELECTED = st.selectbox(
'Select Race',
utils.get_events(YEAR_SELECTED))
SESSION = st.selectbox(
'Select Session',
utils.get_sessions(YEAR_SELECTED, RACE_SELECTED))
laps_df, f1session, drivers = Long_Run_Race_Pace.get_laps(YEAR_SELECTED, RACE_SELECTED, SESSION)
DRIVERS_SELECTED = st.multiselect(
'Remove Outliers',
drivers,
)
laps_df = laps_df.loc[~laps_df.Driver.isin(DRIVERS_SELECTED)]
df = Long_Run_Race_Pace.process_data(laps_df)
Long_Run_Race_Pace.plot(df, f1session)
df.to_csv(f'{YEAR_SELECTED}-{RACE_SELECTED}-{SESSION}.csv')
st.dataframe(pd.read_csv(f'{YEAR_SELECTED}-{RACE_SELECTED}-{SESSION}.csv'))