Spaces:
Running
Running
tracinginsights
commited on
Commit
•
00cd28c
1
Parent(s):
30e864a
Create Heat_Map.py
Browse files- pages/Heat_Map.py +34 -0
pages/Heat_Map.py
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from repo_directory import Heat_Map
|
3 |
+
from repo_directory import button
|
4 |
+
|
5 |
+
# select box for url
|
6 |
+
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")
|
7 |
+
|
8 |
+
race_results_df, drivers = Heat_Map.get_results(URL)
|
9 |
+
|
10 |
+
Heat_Map.get_latest_ergast()
|
11 |
+
|
12 |
+
drivers_df, laps_df, race_names_df, results_df = Heat_Map.load_data()
|
13 |
+
|
14 |
+
# select year
|
15 |
+
|
16 |
+
available_years = race_names_df.year.unique().tolist()
|
17 |
+
available_years.sort(reverse=True)
|
18 |
+
|
19 |
+
YEAR_SELECTED = st.selectbox(
|
20 |
+
'Select year',
|
21 |
+
available_years)
|
22 |
+
|
23 |
+
# select race
|
24 |
+
available_races = race_names_df[race_names_df.year == YEAR_SELECTED].name.tolist()
|
25 |
+
|
26 |
+
RACE_SELECTED = st.selectbox(
|
27 |
+
'Select Race',
|
28 |
+
available_races)
|
29 |
+
|
30 |
+
SELECTED_RACEID = race_names_df[
|
31 |
+
(race_names_df.year == YEAR_SELECTED) & (race_names_df.name == RACE_SELECTED)
|
32 |
+
].raceId.values[0]
|
33 |
+
|
34 |
+
Heat_Map.plot(RACE_SELECTED, SELECTED_RACEID)
|