F1-analysis / pages /Heat_Map.py
tracinginsights's picture
Update pages/Heat_Map.py
3275849
raw
history blame contribute delete
980 Bytes
import streamlit as st
from repo_directory import Heat_Map
from repo_directory import button
# select box for url
URL = st.text_input(label="Race Result URL from Formula1.com", value="https://www.formula1.com/en/results.html/2022/races/1136/mexico/race-result.html")
race_results_df, drivers = Heat_Map.get_results(URL)
Heat_Map.get_latest_ergast()
drivers_df, laps_df, race_names_df, results_df = Heat_Map.load_data()
# select year
available_years = race_names_df.year.unique().tolist()
available_years.sort(reverse=True)
YEAR_SELECTED = st.selectbox(
'Select year',
available_years)
# select race
available_races = race_names_df[race_names_df.year == YEAR_SELECTED].name.tolist()
RACE_SELECTED = st.selectbox(
'Select Race',
available_races)
SELECTED_RACEID = race_names_df[
(race_names_df.year == YEAR_SELECTED) & (race_names_df.name == RACE_SELECTED)
].raceId.values[0]
Heat_Map.plot(RACE_SELECTED, SELECTED_RACEID, laps_df, drivers_df, drivers)