F1-analysis / pages /Download_Raw_Data.py
tracinginsights's picture
Update pages/Download_Raw_Data.py
ca08eb2 verified
raw
history blame
1.72 kB
import streamlit as st
from repo_directory import Download_Raw_Data as dl
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, drivers_list, weather = dl.get_laps(YEAR_SELECTED, RACE_SELECTED, SESSION)
laps.to_csv(f'{YEAR_SELECTED}-{RACE_SELECTED}-{SESSION}.csv')
st.dataframe(pd.read_csv(f'{YEAR_SELECTED}-{RACE_SELECTED}-{SESSION}.csv'))
with open(f'{YEAR_SELECTED}-{RACE_SELECTED}-{SESSION}.csv') as f:
st.download_button('Click to Download LapTimes Data', f, file_name=f'{YEAR_SELECTED}-{RACE_SELECTED}-{SESSION}.csv')
weather.to_csv(f'{YEAR_SELECTED}-{RACE_SELECTED}-{SESSION}-weather.csv')
st.dataframe(pd.read_csv(f'{YEAR_SELECTED}-{RACE_SELECTED}-{SESSION}-weather.csv'))
with open(f'{YEAR_SELECTED}-{RACE_SELECTED}-{SESSION}-weather.csv') as f:
st.download_button('Click to Download Weather Data', f, file_name=f'{YEAR_SELECTED}-{RACE_SELECTED}-{SESSION}-weather.csv')
st.write('For Detailed Telemetry Data')
DRIVERS_SELECTED = st.multiselect(
'Select Driver',
drivers_list)
telemetry = dl.selected_telemetry(DRIVERS_SELECTED, laps)
telemetry.to_csv(f'{YEAR_SELECTED}-{RACE_SELECTED}-{SESSION}-Tel.csv')
st.dataframe(pd.read_csv(f'{YEAR_SELECTED}-{RACE_SELECTED}-{SESSION}-Tel.csv'))
with open(f'{YEAR_SELECTED}-{RACE_SELECTED}-{SESSION}-Tel.csv') as f:
st.download_button('Click to Download Telemetry Data', f, file_name=f'{YEAR_SELECTED}-{RACE_SELECTED}-{SESSION}-Tel.csv')