Spaces:
Runtime error
Runtime error
tracinginsights
commited on
Commit
·
88f8db5
1
Parent(s):
c8bcd1c
Update main.py
Browse files
main.py
CHANGED
@@ -169,6 +169,32 @@ def compute_accelerations(telemetry):
|
|
169 |
|
170 |
return np.round(lon_acc,2), np.round(lat_acc,2)
|
171 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
172 |
@st.cache_data
|
173 |
@app.get("/", response_model=None)
|
174 |
async def root():
|
|
|
169 |
|
170 |
return np.round(lon_acc,2), np.round(lat_acc,2)
|
171 |
|
172 |
+
@st.cache_data
|
173 |
+
@app.get("/wdc", response_model=None)
|
174 |
+
def driver_standings() -> any:
|
175 |
+
YEAR = datetime.datetime.now().year
|
176 |
+
df = pd.DataFrame(
|
177 |
+
pd.read_html(f"https://www.formula1.com/en/results.html/{YEAR}/drivers.html")[0]
|
178 |
+
)
|
179 |
+
df = df[["Driver", "PTS", "Car"]]
|
180 |
+
# reverse the order
|
181 |
+
df = df.sort_values(by="PTS", ascending=False)
|
182 |
+
|
183 |
+
# in Driver column only keep the last 3 characters
|
184 |
+
df["Driver"] = df["Driver"].str[:-3]
|
185 |
+
|
186 |
+
# add colors to the dataframe
|
187 |
+
car_colors = available_data.team_colors(YEAR)
|
188 |
+
df["fill"] = df["Car"].map(car_colors)
|
189 |
+
|
190 |
+
|
191 |
+
# remove rows where points is 0
|
192 |
+
df = df[df["PTS"] != 0]
|
193 |
+
df.reset_index(inplace=True, drop=True)
|
194 |
+
df.rename(columns={"PTS": "Points"}, inplace=True)
|
195 |
+
|
196 |
+
return {"WDC":df.to_dict("records")}
|
197 |
+
|
198 |
@st.cache_data
|
199 |
@app.get("/", response_model=None)
|
200 |
async def root():
|