arre99 commited on
Commit
6269c32
·
1 Parent(s): c6542ed

driver info with lore

Browse files
api_playground.ipynb CHANGED
@@ -2,7 +2,7 @@
2
  "cells": [
3
  {
4
  "cell_type": "code",
5
- "execution_count": 2,
6
  "id": "b7d2515e",
7
  "metadata": {},
8
  "outputs": [
@@ -32,74 +32,6 @@
32
  "# FastF1"
33
  ]
34
  },
35
- {
36
- "cell_type": "code",
37
- "execution_count": 9,
38
- "id": "a2ee421b",
39
- "metadata": {},
40
- "outputs": [
41
- {
42
- "name": "stderr",
43
- "output_type": "stream",
44
- "text": [
45
- "core INFO \tLoading data for Miami Grand Prix - Sprint Qualifying [v3.5.3]\n",
46
- "req INFO \tUsing cached data for session_info\n",
47
- "req INFO \tUsing cached data for driver_info\n",
48
- "core WARNING \tSprint Qualifying is not supported by Ergast! Limited results are calculated from timing data.\n",
49
- "req INFO \tUsing cached data for session_status_data\n",
50
- "req INFO \tUsing cached data for track_status_data\n",
51
- "req INFO \tUsing cached data for _extended_timing_data\n",
52
- "req INFO \tUsing cached data for timing_app_data\n",
53
- "core INFO \tProcessing timing data...\n",
54
- "req INFO \tUsing cached data for weather_data\n",
55
- "req INFO \tUsing cached data for race_control_messages\n",
56
- "core INFO \tFinished loading data for 20 drivers: ['12', '81', '4', '1', '63', '16', '44', '23', '6', '14', '27', '31', '10', '30', '55', '18', '7', '22', '5', '87']\n"
57
- ]
58
- },
59
- {
60
- "name": "stdout",
61
- "output_type": "stream",
62
- "text": [
63
- " DriverNumber BroadcastName Abbreviation DriverId TeamName \\\n",
64
- "12 12 K ANTONELLI ANT Mercedes \n",
65
- "81 81 O PIASTRI PIA McLaren \n",
66
- "4 4 L NORRIS NOR McLaren \n",
67
- "1 1 M VERSTAPPEN VER Red Bull Racing \n",
68
- "63 63 G RUSSELL RUS Mercedes \n",
69
- "\n",
70
- " TeamColor TeamId FirstName LastName FullName ... CountryCode \\\n",
71
- "12 27F4D2 Kimi Antonelli Kimi Antonelli ... \n",
72
- "81 FF8000 Oscar Piastri Oscar Piastri ... \n",
73
- "4 FF8000 Lando Norris Lando Norris ... \n",
74
- "1 3671C6 Max Verstappen Max Verstappen ... \n",
75
- "63 27F4D2 George Russell George Russell ... \n",
76
- "\n",
77
- " Position ClassifiedPosition GridPosition Q1 \\\n",
78
- "12 1.0 NaN 0 days 00:01:27.858000 \n",
79
- "81 2.0 NaN 0 days 00:01:27.951000 \n",
80
- "4 3.0 NaN 0 days 00:01:27.890000 \n",
81
- "1 4.0 NaN 0 days 00:01:27.953000 \n",
82
- "63 5.0 NaN 0 days 00:01:27.688000 \n",
83
- "\n",
84
- " Q2 Q3 Time Status Points \n",
85
- "12 0 days 00:01:27.384000 0 days 00:01:26.482000 NaT NaN \n",
86
- "81 0 days 00:01:27.354000 0 days 00:01:26.527000 NaT NaN \n",
87
- "4 0 days 00:01:27.109000 0 days 00:01:26.582000 NaT NaN \n",
88
- "1 0 days 00:01:27.245000 0 days 00:01:26.737000 NaT NaN \n",
89
- "63 0 days 00:01:27.666000 0 days 00:01:26.791000 NaT NaN \n",
90
- "\n",
91
- "[5 rows x 21 columns]\n"
92
- ]
93
- }
94
- ],
95
- "source": [
96
- "session = fastf1.get_session(2025, \"Miami\", \"sprint qualifying\")\n",
97
- "session.load(telemetry=False)\n",
98
- "results = session.results\n",
99
- "print(results.head())\n",
100
- "#df = results[[\"DriverNumber\", \"Abbreviation\", \"FullName\", \"Position\", \"ClassifiedPosition\", \"GridPosition\", \"Points\", \"Status\", \"Q1\", \"Q2\", \"Q3\"]]"
101
- ]
102
- },
103
  {
104
  "cell_type": "code",
105
  "execution_count": null,
@@ -110,17 +42,18 @@
110
  "name": "stderr",
111
  "output_type": "stream",
112
  "text": [
113
- "core INFO \tLoading data for Japanese Grand Prix - Practice 1 [v3.5.3]\n",
114
  "req INFO \tUsing cached data for session_info\n",
115
  "req INFO \tUsing cached data for driver_info\n",
116
  "req INFO \tUsing cached data for session_status_data\n",
 
117
  "req INFO \tUsing cached data for track_status_data\n",
118
  "req INFO \tUsing cached data for _extended_timing_data\n",
119
  "req INFO \tUsing cached data for timing_app_data\n",
120
  "core INFO \tProcessing timing data...\n",
121
  "req INFO \tUsing cached data for weather_data\n",
122
  "req INFO \tUsing cached data for race_control_messages\n",
123
- "core INFO \tFinished loading data for 20 drivers: ['1', '4', '5', '6', '10', '12', '14', '16', '18', '22', '23', '27', '30', '31', '44', '55', '62', '63', '81', '87']\n"
124
  ]
125
  },
126
  {
@@ -129,423 +62,33 @@
129
  "text": [
130
  "{'Abbreviation': 'VER',\n",
131
  " 'BroadcastName': 'M VERSTAPPEN',\n",
132
- " 'ClassifiedPosition': '',\n",
133
  " 'CountryCode': '',\n",
134
  " 'DriverId': 'max_verstappen',\n",
135
  " 'DriverNumber': '1',\n",
136
  " 'FirstName': 'Max',\n",
137
  " 'FullName': 'Max Verstappen',\n",
138
- " 'GridPosition': nan,\n",
139
  " 'HeadshotUrl': 'https://media.formula1.com/d_driver_fallback_image.png/content/dam/fom-website/drivers/M/MAXVER01_Max_Verstappen/maxver01.png.transform/1col/image.png',\n",
140
  " 'LastName': 'Verstappen',\n",
141
- " 'Points': nan,\n",
142
- " 'Position': nan,\n",
143
  " 'Q1': NaT,\n",
144
  " 'Q2': NaT,\n",
145
  " 'Q3': NaT,\n",
146
- " 'Status': '',\n",
147
  " 'TeamColor': '3671C6',\n",
148
  " 'TeamId': 'red_bull',\n",
149
  " 'TeamName': 'Red Bull Racing',\n",
150
- " 'Time': NaT}\n"
151
  ]
152
  }
153
  ],
154
  "source": [
155
- "session = fastf1.get_session(2025, 3, \"FP1\")\n",
156
  "session.load(telemetry=False)\n",
157
- "driver_info = session.get_driver(\"VER\").to_dict()\n",
158
- "pprint(driver_info)"
159
- ]
160
- },
161
- {
162
- "cell_type": "code",
163
- "execution_count": 24,
164
- "id": "e6de8707",
165
- "metadata": {},
166
- "outputs": [
167
- {
168
- "data": {
169
- "text/html": [
170
- "<div>\n",
171
- "<style scoped>\n",
172
- " .dataframe tbody tr th:only-of-type {\n",
173
- " vertical-align: middle;\n",
174
- " }\n",
175
- "\n",
176
- " .dataframe tbody tr th {\n",
177
- " vertical-align: top;\n",
178
- " }\n",
179
- "\n",
180
- " .dataframe thead th {\n",
181
- " text-align: right;\n",
182
- " }\n",
183
- "</style>\n",
184
- "<table border=\"1\" class=\"dataframe\">\n",
185
- " <thead>\n",
186
- " <tr style=\"text-align: right;\">\n",
187
- " <th></th>\n",
188
- " <th>position</th>\n",
189
- " <th>positionText</th>\n",
190
- " <th>points</th>\n",
191
- " <th>wins</th>\n",
192
- " <th>driverId</th>\n",
193
- " <th>driverNumber</th>\n",
194
- " <th>driverCode</th>\n",
195
- " <th>driverUrl</th>\n",
196
- " <th>givenName</th>\n",
197
- " <th>familyName</th>\n",
198
- " <th>dateOfBirth</th>\n",
199
- " <th>driverNationality</th>\n",
200
- " <th>constructorIds</th>\n",
201
- " <th>constructorUrls</th>\n",
202
- " <th>constructorNames</th>\n",
203
- " <th>constructorNationalities</th>\n",
204
- " </tr>\n",
205
- " </thead>\n",
206
- " <tbody>\n",
207
- " <tr>\n",
208
- " <th>0</th>\n",
209
- " <td>1</td>\n",
210
- " <td>1</td>\n",
211
- " <td>575.0</td>\n",
212
- " <td>19</td>\n",
213
- " <td>max_verstappen</td>\n",
214
- " <td>33</td>\n",
215
- " <td>VER</td>\n",
216
- " <td>http://en.wikipedia.org/wiki/Max_Verstappen</td>\n",
217
- " <td>Max</td>\n",
218
- " <td>Verstappen</td>\n",
219
- " <td>1997-09-30</td>\n",
220
- " <td>Dutch</td>\n",
221
- " <td>[red_bull]</td>\n",
222
- " <td>[http://en.wikipedia.org/wiki/Red_Bull_Racing]</td>\n",
223
- " <td>[Red Bull]</td>\n",
224
- " <td>[Austrian]</td>\n",
225
- " </tr>\n",
226
- " <tr>\n",
227
- " <th>1</th>\n",
228
- " <td>2</td>\n",
229
- " <td>2</td>\n",
230
- " <td>285.0</td>\n",
231
- " <td>2</td>\n",
232
- " <td>perez</td>\n",
233
- " <td>11</td>\n",
234
- " <td>PER</td>\n",
235
- " <td>http://en.wikipedia.org/wiki/Sergio_P%C3%A9rez</td>\n",
236
- " <td>Sergio</td>\n",
237
- " <td>Pérez</td>\n",
238
- " <td>1990-01-26</td>\n",
239
- " <td>Mexican</td>\n",
240
- " <td>[red_bull]</td>\n",
241
- " <td>[http://en.wikipedia.org/wiki/Red_Bull_Racing]</td>\n",
242
- " <td>[Red Bull]</td>\n",
243
- " <td>[Austrian]</td>\n",
244
- " </tr>\n",
245
- " </tbody>\n",
246
- "</table>\n",
247
- "</div>"
248
- ],
249
- "text/plain": [
250
- " position positionText points wins driverId driverNumber \\\n",
251
- "0 1 1 575.0 19 max_verstappen 33 \n",
252
- "1 2 2 285.0 2 perez 11 \n",
253
- "\n",
254
- " driverCode driverUrl givenName \\\n",
255
- "0 VER http://en.wikipedia.org/wiki/Max_Verstappen Max \n",
256
- "1 PER http://en.wikipedia.org/wiki/Sergio_P%C3%A9rez Sergio \n",
257
- "\n",
258
- " familyName dateOfBirth driverNationality constructorIds \\\n",
259
- "0 Verstappen 1997-09-30 Dutch [red_bull] \n",
260
- "1 Pérez 1990-01-26 Mexican [red_bull] \n",
261
- "\n",
262
- " constructorUrls constructorNames \\\n",
263
- "0 [http://en.wikipedia.org/wiki/Red_Bull_Racing] [Red Bull] \n",
264
- "1 [http://en.wikipedia.org/wiki/Red_Bull_Racing] [Red Bull] \n",
265
- "\n",
266
- " constructorNationalities \n",
267
- "0 [Austrian] \n",
268
- "1 [Austrian] "
269
- ]
270
- },
271
- "execution_count": 24,
272
- "metadata": {},
273
- "output_type": "execute_result"
274
- }
275
- ],
276
- "source": [
277
- "ergastandings = fastf1.ergast.Ergast()\n",
278
- "driver_standings = ergastandings.get_driver_standings(2023).content[0]\n",
279
- "driver_standings.head(2)"
280
- ]
281
- },
282
- {
283
- "cell_type": "code",
284
- "execution_count": 33,
285
- "id": "feeb4592",
286
- "metadata": {},
287
- "outputs": [
288
- {
289
- "data": {
290
- "text/html": [
291
- "<div>\n",
292
- "<style scoped>\n",
293
- " .dataframe tbody tr th:only-of-type {\n",
294
- " vertical-align: middle;\n",
295
- " }\n",
296
- "\n",
297
- " .dataframe tbody tr th {\n",
298
- " vertical-align: top;\n",
299
- " }\n",
300
- "\n",
301
- " .dataframe thead th {\n",
302
- " text-align: right;\n",
303
- " }\n",
304
- "</style>\n",
305
- "<table border=\"1\" class=\"dataframe\">\n",
306
- " <thead>\n",
307
- " <tr style=\"text-align: right;\">\n",
308
- " <th></th>\n",
309
- " <th>position</th>\n",
310
- " <th>positionText</th>\n",
311
- " <th>points</th>\n",
312
- " <th>wins</th>\n",
313
- " <th>constructorId</th>\n",
314
- " <th>constructorUrl</th>\n",
315
- " <th>constructorName</th>\n",
316
- " <th>constructorNationality</th>\n",
317
- " </tr>\n",
318
- " </thead>\n",
319
- " <tbody>\n",
320
- " <tr>\n",
321
- " <th>0</th>\n",
322
- " <td>1</td>\n",
323
- " <td>1</td>\n",
324
- " <td>362.0</td>\n",
325
- " <td>7</td>\n",
326
- " <td>mclaren</td>\n",
327
- " <td>http://en.wikipedia.org/wiki/McLaren</td>\n",
328
- " <td>McLaren</td>\n",
329
- " <td>British</td>\n",
330
- " </tr>\n",
331
- " <tr>\n",
332
- " <th>1</th>\n",
333
- " <td>2</td>\n",
334
- " <td>2</td>\n",
335
- " <td>165.0</td>\n",
336
- " <td>0</td>\n",
337
- " <td>ferrari</td>\n",
338
- " <td>http://en.wikipedia.org/wiki/Scuderia_Ferrari</td>\n",
339
- " <td>Ferrari</td>\n",
340
- " <td>Italian</td>\n",
341
- " </tr>\n",
342
- " <tr>\n",
343
- " <th>2</th>\n",
344
- " <td>3</td>\n",
345
- " <td>3</td>\n",
346
- " <td>159.0</td>\n",
347
- " <td>0</td>\n",
348
- " <td>mercedes</td>\n",
349
- " <td>http://en.wikipedia.org/wiki/Mercedes-Benz_in_...</td>\n",
350
- " <td>Mercedes</td>\n",
351
- " <td>German</td>\n",
352
- " </tr>\n",
353
- " <tr>\n",
354
- " <th>3</th>\n",
355
- " <td>4</td>\n",
356
- " <td>4</td>\n",
357
- " <td>144.0</td>\n",
358
- " <td>2</td>\n",
359
- " <td>red_bull</td>\n",
360
- " <td>http://en.wikipedia.org/wiki/Red_Bull_Racing</td>\n",
361
- " <td>Red Bull</td>\n",
362
- " <td>Austrian</td>\n",
363
- " </tr>\n",
364
- " <tr>\n",
365
- " <th>4</th>\n",
366
- " <td>5</td>\n",
367
- " <td>5</td>\n",
368
- " <td>54.0</td>\n",
369
- " <td>0</td>\n",
370
- " <td>williams</td>\n",
371
- " <td>http://en.wikipedia.org/wiki/Williams_Grand_Pr...</td>\n",
372
- " <td>Williams</td>\n",
373
- " <td>British</td>\n",
374
- " </tr>\n",
375
- " <tr>\n",
376
- " <th>5</th>\n",
377
- " <td>6</td>\n",
378
- " <td>6</td>\n",
379
- " <td>28.0</td>\n",
380
- " <td>0</td>\n",
381
- " <td>rb</td>\n",
382
- " <td>http://en.wikipedia.org/wiki/RB_Formula_One_Team</td>\n",
383
- " <td>RB F1 Team</td>\n",
384
- " <td>Italian</td>\n",
385
- " </tr>\n",
386
- " <tr>\n",
387
- " <th>6</th>\n",
388
- " <td>7</td>\n",
389
- " <td>7</td>\n",
390
- " <td>26.0</td>\n",
391
- " <td>0</td>\n",
392
- " <td>haas</td>\n",
393
- " <td>http://en.wikipedia.org/wiki/Haas_F1_Team</td>\n",
394
- " <td>Haas F1 Team</td>\n",
395
- " <td>American</td>\n",
396
- " </tr>\n",
397
- " <tr>\n",
398
- " <th>7</th>\n",
399
- " <td>8</td>\n",
400
- " <td>8</td>\n",
401
- " <td>16.0</td>\n",
402
- " <td>0</td>\n",
403
- " <td>sauber</td>\n",
404
- " <td>http://en.wikipedia.org/wiki/Sauber_Motorsport</td>\n",
405
- " <td>Sauber</td>\n",
406
- " <td>Swiss</td>\n",
407
- " </tr>\n",
408
- " <tr>\n",
409
- " <th>8</th>\n",
410
- " <td>9</td>\n",
411
- " <td>9</td>\n",
412
- " <td>16.0</td>\n",
413
- " <td>0</td>\n",
414
- " <td>aston_martin</td>\n",
415
- " <td>http://en.wikipedia.org/wiki/Aston_Martin_in_F...</td>\n",
416
- " <td>Aston Martin</td>\n",
417
- " <td>British</td>\n",
418
- " </tr>\n",
419
- " <tr>\n",
420
- " <th>9</th>\n",
421
- " <td>10</td>\n",
422
- " <td>10</td>\n",
423
- " <td>11.0</td>\n",
424
- " <td>0</td>\n",
425
- " <td>alpine</td>\n",
426
- " <td>http://en.wikipedia.org/wiki/Alpine_F1_Team</td>\n",
427
- " <td>Alpine F1 Team</td>\n",
428
- " <td>French</td>\n",
429
- " </tr>\n",
430
- " </tbody>\n",
431
- "</table>\n",
432
- "</div>"
433
- ],
434
- "text/plain": [
435
- " position positionText points wins constructorId \\\n",
436
- "0 1 1 362.0 7 mclaren \n",
437
- "1 2 2 165.0 0 ferrari \n",
438
- "2 3 3 159.0 0 mercedes \n",
439
- "3 4 4 144.0 2 red_bull \n",
440
- "4 5 5 54.0 0 williams \n",
441
- "5 6 6 28.0 0 rb \n",
442
- "6 7 7 26.0 0 haas \n",
443
- "7 8 8 16.0 0 sauber \n",
444
- "8 9 9 16.0 0 aston_martin \n",
445
- "9 10 10 11.0 0 alpine \n",
446
- "\n",
447
- " constructorUrl constructorName \\\n",
448
- "0 http://en.wikipedia.org/wiki/McLaren McLaren \n",
449
- "1 http://en.wikipedia.org/wiki/Scuderia_Ferrari Ferrari \n",
450
- "2 http://en.wikipedia.org/wiki/Mercedes-Benz_in_... Mercedes \n",
451
- "3 http://en.wikipedia.org/wiki/Red_Bull_Racing Red Bull \n",
452
- "4 http://en.wikipedia.org/wiki/Williams_Grand_Pr... Williams \n",
453
- "5 http://en.wikipedia.org/wiki/RB_Formula_One_Team RB F1 Team \n",
454
- "6 http://en.wikipedia.org/wiki/Haas_F1_Team Haas F1 Team \n",
455
- "7 http://en.wikipedia.org/wiki/Sauber_Motorsport Sauber \n",
456
- "8 http://en.wikipedia.org/wiki/Aston_Martin_in_F... Aston Martin \n",
457
- "9 http://en.wikipedia.org/wiki/Alpine_F1_Team Alpine F1 Team \n",
458
- "\n",
459
- " constructorNationality \n",
460
- "0 British \n",
461
- "1 Italian \n",
462
- "2 German \n",
463
- "3 Austrian \n",
464
- "4 British \n",
465
- "5 Italian \n",
466
- "6 American \n",
467
- "7 Swiss \n",
468
- "8 British \n",
469
- "9 French "
470
- ]
471
- },
472
- "execution_count": 33,
473
- "metadata": {},
474
- "output_type": "execute_result"
475
- }
476
- ],
477
- "source": [
478
- "ergastandings = fastf1.ergast.Ergast()\n",
479
- "constructor_standings = ergastandings.get_constructor_standings(2025).content[0]\n",
480
- "constructor_standings.head(10)"
481
- ]
482
- },
483
- {
484
- "cell_type": "code",
485
- "execution_count": 2,
486
- "id": "32f180c1",
487
- "metadata": {},
488
- "outputs": [
489
- {
490
- "name": "stderr",
491
- "output_type": "stream",
492
- "text": [
493
- "req WARNING \tDEFAULT CACHE ENABLED! (173.47 MB) /home/arre/.cache/fastf1\n"
494
- ]
495
- },
496
- {
497
- "name": "stdout",
498
- "output_type": "stream",
499
- "text": [
500
- "RoundNumber 1\n",
501
- "Country Australia\n",
502
- "Location Melbourne\n",
503
- "OfficialEventName \n",
504
- "EventDate 2007-03-18 03:00:00\n",
505
- "EventName Australian Grand Prix\n",
506
- "EventFormat conventional\n",
507
- "Session1 Practice 1\n",
508
- "Session1Date None\n",
509
- "Session1DateUtc 2007-03-16 00:00:00\n",
510
- "Session2 Practice 2\n",
511
- "Session2Date None\n",
512
- "Session2DateUtc 2007-03-16 00:00:00\n",
513
- "Session3 Practice 3\n",
514
- "Session3Date None\n",
515
- "Session3DateUtc 2007-03-17 00:00:00\n",
516
- "Session4 Qualifying\n",
517
- "Session4Date None\n",
518
- "Session4DateUtc 2007-03-17 00:00:00\n",
519
- "Session5 Race\n",
520
- "Session5Date None\n",
521
- "Session5DateUtc 2007-03-18 03:00:00\n",
522
- "F1ApiSupport False\n",
523
- "Name: 0, dtype: object\n",
524
- "Season calendar:\n",
525
- "Round 1 : Australian Grand Prix - Melbourne, Australia (2007-03-16 - 2007-03-18)\n",
526
- "Round 2 : Malaysian Grand Prix - Kuala Lumpur, Malaysia (2007-04-06 - 2007-04-08)\n",
527
- "Round 3 : Bahrain Grand Prix - Sakhir, Bahrain (2007-04-13 - 2007-04-15)\n",
528
- "Round 4 : Spanish Grand Prix - Montmeló, Spain (2007-05-11 - 2007-05-13)\n",
529
- "Round 5 : Monaco Grand Prix - Monte-Carlo, Monaco (2007-05-25 - 2007-05-27)\n",
530
- "Round 6 : Canadian Grand Prix - Montreal, Canada (2007-06-08 - 2007-06-10)\n",
531
- "Round 7 : United States Grand Prix - Indianapolis, USA (2007-06-15 - 2007-06-17)\n",
532
- "Round 8 : French Grand Prix - Magny Cours, France (2007-06-29 - 2007-07-01)\n",
533
- "Round 9 : British Grand Prix - Silverstone, UK (2007-07-06 - 2007-07-08)\n",
534
- "Round 10 : European Grand Prix - Nürburg, Germany (2007-07-20 - 2007-07-22)\n",
535
- "Round 11 : Hungarian Grand Prix - Budapest, Hungary (2007-08-03 - 2007-08-05)\n",
536
- "Round 12 : Turkish Grand Prix - Istanbul, Turkey (2007-08-24 - 2007-08-26)\n",
537
- "Round 13 : Italian Grand Prix - Monza, Italy (2007-09-07 - 2007-09-09)\n",
538
- "Round 14 : Belgian Grand Prix - Spa, Belgium (2007-09-14 - 2007-09-16)\n",
539
- "Round 15 : Japanese Grand Prix - Oyama, Japan (2007-09-28 - 2007-09-30)\n",
540
- "Round 16 : Chinese Grand Prix - Shanghai, China (2007-10-05 - 2007-10-07)\n",
541
- "Round 17 : Brazilian Grand Prix - São Paulo, Brazil (2007-10-19 - 2007-10-21)\n"
542
- ]
543
- }
544
- ],
545
- "source": [
546
- "schedule = fastf1.get_event_schedule(2007)\n",
547
- "print(schedule.iloc[0])\n",
548
- "print(parse_season_calendar(schedule))"
549
  ]
550
  },
551
  {
 
2
  "cells": [
3
  {
4
  "cell_type": "code",
5
+ "execution_count": 10,
6
  "id": "b7d2515e",
7
  "metadata": {},
8
  "outputs": [
 
32
  "# FastF1"
33
  ]
34
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
  {
36
  "cell_type": "code",
37
  "execution_count": null,
 
42
  "name": "stderr",
43
  "output_type": "stream",
44
  "text": [
45
+ "core INFO \tLoading data for Japanese Grand Prix - Race [v3.5.3]\n",
46
  "req INFO \tUsing cached data for session_info\n",
47
  "req INFO \tUsing cached data for driver_info\n",
48
  "req INFO \tUsing cached data for session_status_data\n",
49
+ "req INFO \tUsing cached data for lap_count\n",
50
  "req INFO \tUsing cached data for track_status_data\n",
51
  "req INFO \tUsing cached data for _extended_timing_data\n",
52
  "req INFO \tUsing cached data for timing_app_data\n",
53
  "core INFO \tProcessing timing data...\n",
54
  "req INFO \tUsing cached data for weather_data\n",
55
  "req INFO \tUsing cached data for race_control_messages\n",
56
+ "core INFO \tFinished loading data for 20 drivers: ['1', '4', '81', '16', '63', '12', '44', '6', '23', '87', '14', '22', '10', '55', '7', '27', '30', '31', '5', '18']\n"
57
  ]
58
  },
59
  {
 
62
  "text": [
63
  "{'Abbreviation': 'VER',\n",
64
  " 'BroadcastName': 'M VERSTAPPEN',\n",
65
+ " 'ClassifiedPosition': '1',\n",
66
  " 'CountryCode': '',\n",
67
  " 'DriverId': 'max_verstappen',\n",
68
  " 'DriverNumber': '1',\n",
69
  " 'FirstName': 'Max',\n",
70
  " 'FullName': 'Max Verstappen',\n",
71
+ " 'GridPosition': 1.0,\n",
72
  " 'HeadshotUrl': 'https://media.formula1.com/d_driver_fallback_image.png/content/dam/fom-website/drivers/M/MAXVER01_Max_Verstappen/maxver01.png.transform/1col/image.png',\n",
73
  " 'LastName': 'Verstappen',\n",
74
+ " 'Points': 25.0,\n",
75
+ " 'Position': 1.0,\n",
76
  " 'Q1': NaT,\n",
77
  " 'Q2': NaT,\n",
78
  " 'Q3': NaT,\n",
79
+ " 'Status': 'Finished',\n",
80
  " 'TeamColor': '3671C6',\n",
81
  " 'TeamId': 'red_bull',\n",
82
  " 'TeamName': 'Red Bull Racing',\n",
83
+ " 'Time': Timedelta('0 days 01:22:06.983000')}\n"
84
  ]
85
  }
86
  ],
87
  "source": [
88
+ "session = fastf1.get_session(2025, 3, \"R\")\n",
89
  "session.load(telemetry=False)\n",
90
+ "circuit_info = session.get_circuit_info()\n",
91
+ "pprint(circuit_info)"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92
  ]
93
  },
94
  {
app.py CHANGED
@@ -7,7 +7,8 @@ from utils.constants import (
7
  CONSTRUCTOR_NAMES,
8
  CURRENT_YEAR,
9
  AVAILABLE_SESSION_TYPES,
10
- DROPDOWN_SESSION_TYPES
 
11
  )
12
 
13
  iface_driver_championship_standings = gr.Interface(
@@ -79,6 +80,15 @@ iface_session_results = gr.Interface(
79
  description="Get the session results for the given Grand Prix"
80
  )
81
 
 
 
 
 
 
 
 
 
 
82
 
83
  named_interfaces = {
84
  "Driver Championship Standings": iface_driver_championship_standings,
@@ -86,7 +96,8 @@ named_interfaces = {
86
  "Event Info": iface_event_info,
87
  "Season Calendar": iface_season_calendar,
88
  "Track Visualizations": iface_track_visualization,
89
- "Session Results": iface_session_results
 
90
  }
91
 
92
  # Tab names and interfaces
 
7
  CONSTRUCTOR_NAMES,
8
  CURRENT_YEAR,
9
  AVAILABLE_SESSION_TYPES,
10
+ DROPDOWN_SESSION_TYPES,
11
+ DRIVER_DETAILS
12
  )
13
 
14
  iface_driver_championship_standings = gr.Interface(
 
80
  description="Get the session results for the given Grand Prix"
81
  )
82
 
83
+ iface_driver_info = gr.Interface(
84
+ fn=tools.get_driver_info,
85
+ inputs=[
86
+ gr.Dropdown(label="Driver", choices=DRIVER_NAMES)
87
+ ],
88
+ outputs="text",
89
+ title="Driver Info",
90
+ description="Get personal information about a driver"
91
+ )
92
 
93
  named_interfaces = {
94
  "Driver Championship Standings": iface_driver_championship_standings,
 
96
  "Event Info": iface_event_info,
97
  "Season Calendar": iface_season_calendar,
98
  "Track Visualizations": iface_track_visualization,
99
+ "Session Results": iface_session_results,
100
+ "Driver Info": iface_driver_info
101
  }
102
 
103
  # Tab names and interfaces
assets/driver_details.json ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "Max Verstappen": {
3
+ "birth_date": "1997-09-30",
4
+ "number": 1,
5
+ "team": "Red Bull Racing",
6
+ "nationality": "🇳🇱 Netherlands"
7
+ },
8
+ "Liam Lawson": {
9
+ "birth_date": "2002-02-11",
10
+ "number": 30,
11
+ "team": "Red Bull Racing",
12
+ "nationality": "🇳🇿 New Zealand"
13
+ },
14
+ "Charles Leclerc": {
15
+ "birth_date": "1997-10-16",
16
+ "number": 16,
17
+ "team": "Ferrari",
18
+ "nationality": "🇲🇨 Monaco"
19
+ },
20
+ "Lewis Hamilton": {
21
+ "birth_date": "1985-01-07",
22
+ "number": 44,
23
+ "team": "Ferrari",
24
+ "nationality": "🇬🇧 United Kingdom"
25
+ },
26
+ "George Russell": {
27
+ "birth_date": "1998-02-15",
28
+ "number": 63,
29
+ "team": "Mercedes",
30
+ "nationality": "🇬🇧 United Kingdom"
31
+ },
32
+ "Andrea Kimi Antonelli": {
33
+ "birth_date": "2006-08-25",
34
+ "number": 12,
35
+ "team": "Mercedes",
36
+ "nationality": "🇮🇹 Italy"
37
+ },
38
+ "Lando Norris": {
39
+ "birth_date": "1999-11-13",
40
+ "number": 4,
41
+ "team": "McLaren",
42
+ "nationality": "🇬🇧 United Kingdom"
43
+ },
44
+ "Oscar Piastri": {
45
+ "birth_date": "2001-04-06",
46
+ "number": 81,
47
+ "team": "McLaren",
48
+ "nationality": "🇦🇺 Australia"
49
+ },
50
+ "Fernando Alonso": {
51
+ "birth_date": "1981-07-29",
52
+ "number": 14,
53
+ "team": "Aston Martin",
54
+ "nationality": "🇪🇸 Spain"
55
+ },
56
+ "Lance Stroll": {
57
+ "birth_date": "1998-10-29",
58
+ "number": 18,
59
+ "team": "Aston Martin",
60
+ "nationality": "🇨🇦 Canada"
61
+ },
62
+ "Pierre Gasly": {
63
+ "birth_date": "1996-02-07",
64
+ "number": 10,
65
+ "team": "Alpine",
66
+ "nationality": "🇫🇷 France"
67
+ },
68
+ "Jack Doohan": {
69
+ "birth_date": "2003-01-20",
70
+ "number": 7,
71
+ "team": "Alpine",
72
+ "nationality": "🇦🇺 Australia"
73
+ },
74
+ "Esteban Ocon": {
75
+ "birth_date": "1996-09-17",
76
+ "number": 31,
77
+ "team": "Haas",
78
+ "nationality": "🇫🇷 France"
79
+ },
80
+ "Oliver Bearman": {
81
+ "birth_date": "2005-05-08",
82
+ "number": 87,
83
+ "team": "Haas",
84
+ "nationality": "🇬🇧 United Kingdom"
85
+ },
86
+ "Yuki Tsunoda": {
87
+ "birth_date": "2000-05-11",
88
+ "number": 22,
89
+ "team": "Racing Bulls",
90
+ "nationality": "🇯🇵 Japan"
91
+ },
92
+ "Isack Hadjar": {
93
+ "birth_date": "2004-09-28",
94
+ "number": 6,
95
+ "team": "Racing Bulls",
96
+ "nationality": "🇫🇷 France"
97
+ },
98
+ "Alexander Albon": {
99
+ "birth_date": "1996-03-23",
100
+ "number": 23,
101
+ "team": "Williams",
102
+ "nationality": "🇹🇭 Thailand"
103
+ },
104
+ "Carlos Sainz Jr": {
105
+ "birth_date": "1994-09-01",
106
+ "number": 55,
107
+ "team": "Williams",
108
+ "nationality": "🇪🇸 Spain"
109
+ },
110
+ "Nico Hülkenberg": {
111
+ "birth_date": "1987-08-19",
112
+ "number": 27,
113
+ "team": "Kick Sauber",
114
+ "nationality": "🇩🇪 Germany"
115
+ },
116
+ "Gabriel Bortoleto": {
117
+ "birth_date": "2004-10-14",
118
+ "number": 5,
119
+ "team": "Kick Sauber",
120
+ "nationality": "🇧🇷 Brazil"
121
+ }
122
+ }
assets/driver_details_with_summaries.json ADDED
@@ -0,0 +1,142 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "Max Verstappen": {
3
+ "birth_date": "1997-09-30",
4
+ "number": 1,
5
+ "team": "Red Bull Racing",
6
+ "nationality": "🇳🇱 Netherlands",
7
+ "summary": "Son of former F1 driver Jos Verstappen, Max was destined for racing greatness from a young age. He made history by becoming the youngest F1 driver at 17 and the youngest race winner at 18. His aggressive yet calculated driving style has earned him multiple World Championships with Red Bull Racing, making him one of the most dominant drivers in the sport's history."
8
+ },
9
+ "Liam Lawson": {
10
+ "birth_date": "2002-02-11",
11
+ "number": 30,
12
+ "team": "Red Bull Racing",
13
+ "nationality": "🇳🇿 New Zealand",
14
+ "summary": "Hailing from New Zealand, Lawson quickly rose through the ranks of single-seater racing, impressing in Formula 2 and DTM. His composed performances as a reserve driver for Red Bull earned him a race seat, showcasing his ability to adapt quickly to different racing disciplines and challenging conditions."
15
+ },
16
+ "Charles Leclerc": {
17
+ "birth_date": "1997-10-16",
18
+ "number": 16,
19
+ "team": "Ferrari",
20
+ "nationality": "🇲🇨 Monaco",
21
+ "summary": "A product of the Ferrari Driver Academy, Leclerc's journey to F1 was marked by personal tragedy and triumph. The Monegasque driver won back-to-back championships in GP3 and F2 before joining Sauber and then Ferrari. Known for his qualifying pace and racecraft, he became Ferrari's leading driver and a consistent championship contender."
22
+ },
23
+ "Lewis Hamilton": {
24
+ "birth_date": "1985-01-07",
25
+ "number": 44,
26
+ "team": "Ferrari",
27
+ "nationality": "🇬🇧 United Kingdom",
28
+ "summary": "One of the most successful drivers in F1 history, Hamilton's journey began in karting where he was signed by McLaren at age 13. The seven-time world champion made history as the first black driver in F1 and holds numerous records, including most race wins and pole positions. His move to Ferrari in 2025 marked a new chapter in his legendary career."
29
+ },
30
+ "George Russell": {
31
+ "birth_date": "1998-02-15",
32
+ "number": 63,
33
+ "team": "Mercedes",
34
+ "nationality": "🇬🇧 United Kingdom",
35
+ "summary": "Dubbed 'Mr. Saturday' for his exceptional qualifying performances, Russell's path to F1 was paved with success in junior categories, including winning the GP3 and F2 championships in consecutive years. After impressing at Williams, he earned a Mercedes seat, where he continues to showcase his speed and racecraft against the sport's best."
36
+ },
37
+ "Andrea Kimi Antonelli": {
38
+ "birth_date": "2006-08-25",
39
+ "number": 12,
40
+ "team": "Mercedes",
41
+ "nationality": "🇮🇹 Italy",
42
+ "summary": "The youngest driver on the grid, Antonelli is one of the most exciting prospects in motorsport. After dominating the junior categories with multiple championships, he made an early jump to F1 with Mercedes, skipping F2. His rapid progression and natural talent have drawn comparisons to Max Verstappen's meteoric rise in the sport."
43
+ },
44
+ "Lando Norris": {
45
+ "birth_date": "1999-11-13",
46
+ "number": 4,
47
+ "team": "McLaren",
48
+ "nationality": "🇬🇧 United Kingdom",
49
+ "summary": "Known for his charismatic personality and raw speed, Norris rose through the ranks of karting and single-seaters before joining McLaren. The British driver has developed into one of F1's brightest talents, known for his consistency, racecraft, and entertaining social media presence. His performances have made him a fan favorite and a future championship contender."
50
+ },
51
+ "Oscar Piastri": {
52
+ "birth_date": "2001-04-06",
53
+ "number": 81,
54
+ "team": "McLaren",
55
+ "nationality": "🇦🇺 Australia",
56
+ "summary": "The Australian sensation made history by winning three consecutive junior championships (Formula Renault, F3, and F2) before his F1 debut. After a year on the sidelines as Alpine's reserve driver, Piastri joined McLaren where he quickly established himself as one of the grid's most promising talents, known for his technical feedback and race intelligence."
57
+ },
58
+ "Fernando Alonso": {
59
+ "birth_date": "1981-07-29",
60
+ "number": 14,
61
+ "team": "Aston Martin",
62
+ "nationality": "🇪🇸 Spain",
63
+ "summary": "A two-time World Champion, Alonso is known for his incredible racecraft and fierce determination. The Spaniard made his F1 debut with Minardi in 2001 before winning back-to-back titles with Renault. His career has seen him race for top teams including Ferrari and McLaren, and he continues to be one of the most respected and experienced drivers on the grid with Aston Martin."
64
+ },
65
+ "Lance Stroll": {
66
+ "birth_date": "1998-10-29",
67
+ "number": 18,
68
+ "team": "Aston Martin",
69
+ "nationality": "🇨🇦 Canada",
70
+ "summary": "The son of billionaire Lawrence Stroll, Lance has worked hard to prove himself beyond his family connections. After winning the European F3 championship, he made history as the first Canadian to take an F1 podium in the wet at Baku 2017. His smooth driving style and wet-weather prowess have earned him respect in the paddock."
71
+ },
72
+ "Pierre Gasly": {
73
+ "birth_date": "1996-02-07",
74
+ "number": 10,
75
+ "team": "Alpine",
76
+ "nationality": "🇫🇷 France",
77
+ "summary": "Gasly's journey to F1 was marked by success in junior categories, including winning the 2016 GP2 championship. After a challenging stint at Red Bull, he found his stride at AlphaTauri, securing a memorable victory at Monza in 2020. The Frenchman is known for his emotional personality and strong work ethic."
78
+ },
79
+ "Jack Doohan": {
80
+ "birth_date": "2003-01-20",
81
+ "number": 7,
82
+ "team": "Alpine",
83
+ "nationality": "🇦🇺 Australia",
84
+ "summary": "Son of motorcycle legend Mick Doohan, Jack has carved his own path in four-wheel racing. The Australian impressed in F2 with multiple race wins and pole positions before earning his F1 debut with Alpine. Known for his technical feedback and smooth driving style, he represents the next generation of Australian racing talent."
85
+ },
86
+ "Esteban Ocon": {
87
+ "birth_date": "1996-09-17",
88
+ "number": 31,
89
+ "team": "Haas",
90
+ "nationality": "🇫🇷 France",
91
+ "summary": "Ocon's journey to F1 was marked by financial challenges before catching the eye of Mercedes' junior program. After winning the 2015 GP3 series and serving as a reserve driver, he made his debut with Manor Racing. The Frenchman is known for his consistency, racecraft, and memorable battles with teammate Sergio Perez during their Force India days."
92
+ },
93
+ "Oliver Bearman": {
94
+ "birth_date": "2005-05-08",
95
+ "number": 87,
96
+ "team": "Haas",
97
+ "nationality": "🇬🇧 United Kingdom",
98
+ "summary": "One of the youngest drivers on the grid, Bearman made a name for himself with dominant performances in Italian F4 and Formula 3. The British driver's rapid progression through the junior categories earned him a spot in Ferrari's Driver Academy and a race seat with Haas. His technical understanding and mature approach belie his young age."
99
+ },
100
+ "Yuki Tsunoda": {
101
+ "birth_date": "2000-05-11",
102
+ "number": 22,
103
+ "team": "Racing Bulls",
104
+ "nationality": "🇯🇵 Japan",
105
+ "summary": "The first Japanese driver in F1 since 2014, Tsunoda's rapid rise through the ranks was supported by Honda's young driver program. After finishing third in F2, he made his F1 debut with AlphaTauri. Known for his aggressive driving style and passionate radio messages, Tsunoda has developed into a consistent points scorer for Racing Bulls."
106
+ },
107
+ "Isack Hadjar": {
108
+ "birth_date": "2004-09-28",
109
+ "number": 6,
110
+ "team": "Racing Bulls",
111
+ "nationality": "🇫🇷 France",
112
+ "summary": "Hadjar emerged as one of the most exciting young talents in junior single-seater racing, impressing in F3 before moving up to F2. The French-Algerian driver's smooth driving style and natural speed earned him a spot in Red Bull's junior program. His rapid adaptation to different racing categories has marked him as a future star."
113
+ },
114
+ "Alexander Albon": {
115
+ "birth_date": "1996-03-23",
116
+ "number": 23,
117
+ "team": "Williams",
118
+ "nationality": "🇹🇭 Thailand",
119
+ "summary": "Born to a British father and Thai mother, Albon's journey to F1 included being dropped by Red Bull's junior program before fighting his way back through GP3 and F2. After strong performances with Toro Rosso and Red Bull, he found a home at Williams where his consistent point-scoring has made him team leader. His smooth driving style and technical feedback are among his greatest strengths."
120
+ },
121
+ "Carlos Sainz Jr": {
122
+ "birth_date": "1994-09-01",
123
+ "number": 55,
124
+ "team": "Williams",
125
+ "nationality": "🇪🇸 Spain",
126
+ "summary": "Son of rally legend Carlos Sainz, the Spaniard has forged his own successful career in F1. After learning his craft at Toro Rosso, he impressed at Renault, McLaren, and Ferrari before moving to Williams. Known for his consistency and intelligence behind the wheel, Sainz is regarded as one of the most complete drivers on the grid."
127
+ },
128
+ "Nico Hülkenberg": {
129
+ "birth_date": "1987-08-19",
130
+ "number": 27,
131
+ "team": "Kick Sauber",
132
+ "nationality": "🇩🇪 Germany",
133
+ "summary": "The experienced German driver holds the record for most F1 starts without a podium. After winning titles in A1GP and GP2, Hülkenberg made his F1 debut with Williams in 2010. Known for his qualifying prowess and technical feedback, he returned to F1 with Haas before moving to Kick Sauber, bringing valuable experience to the team."
134
+ },
135
+ "Gabriel Bortoleto": {
136
+ "birth_date": "2004-10-14",
137
+ "number": 5,
138
+ "team": "Kick Sauber",
139
+ "nationality": "🇧🇷 Brazil",
140
+ "summary": "The latest Brazilian talent to reach F1, Bortoleto made waves by winning the 2023 F3 championship in dominant fashion. His smooth driving style and racecraft earned him a spot in the McLaren young driver program before securing a race seat with Kick Sauber. The young Brazilian carries the hopes of a nation that has produced legends like Senna, Piquet, and Massa."
141
+ }
142
+ }
tools.py CHANGED
@@ -2,10 +2,8 @@
2
  Here we implement the MCP tools
3
 
4
  Tools to implement
5
- - session result
6
  - driver info
7
  - compare drivers
8
-
9
  """
10
 
11
  import json
@@ -18,7 +16,10 @@ from fastf1.core import Session
18
 
19
  # Local modules
20
  from utils import parser_utils, track_utils
21
- from utils.constants import AVAILABLE_SESSION_TYPES
 
 
 
22
 
23
  # Custom types
24
  gp = Union[str, int]
@@ -127,6 +128,11 @@ def get_session_results(year: int, round: gp, session_type: session_type) -> pd.
127
  df[["Q1", "Q2", "Q3"]] = df[["Q1", "Q2", "Q3"]].apply(lambda x: x.dt.total_seconds().apply(lambda y: f"{int(y//60):02d}:{int(y%60):02d}.{int(y%1*1000):03d}" if pd.notna(y) else "-"))
128
  df = df[["Pos", "Name", "Q1", "Q2", "Q3"]]
129
  return df
 
 
 
 
 
130
 
131
 
132
 
 
2
  Here we implement the MCP tools
3
 
4
  Tools to implement
 
5
  - driver info
6
  - compare drivers
 
7
  """
8
 
9
  import json
 
16
 
17
  # Local modules
18
  from utils import parser_utils, track_utils
19
+ from utils.constants import (
20
+ AVAILABLE_SESSION_TYPES,
21
+ DRIVER_DETAILS
22
+ )
23
 
24
  # Custom types
25
  gp = Union[str, int]
 
128
  df[["Q1", "Q2", "Q3"]] = df[["Q1", "Q2", "Q3"]].apply(lambda x: x.dt.total_seconds().apply(lambda y: f"{int(y//60):02d}:{int(y%60):02d}.{int(y%1*1000):03d}" if pd.notna(y) else "-"))
129
  df = df[["Pos", "Name", "Q1", "Q2", "Q3"]]
130
  return df
131
+
132
+ def get_driver_info(driver_name: str) -> str:
133
+ driver = DRIVER_DETAILS[driver_name]
134
+ driver_info_string = f"{driver_name} ({driver['birth_date']})\n{driver['team']} #{driver['number']}\n{driver['nationality']}\n\n{driver['summary']}"
135
+ return driver_info_string
136
 
137
 
138
 
utils/constants.py CHANGED
@@ -1,6 +1,9 @@
1
  import json
2
  import datetime
3
 
 
 
 
4
  AVAILABLE_SESSION_TYPES = [
5
  "fp1", "fp2", "fp3", "q", "s", "ss", "sq", "r",
6
  "practice 1", "practice 2", "practice 3", "sprint",
@@ -13,12 +16,10 @@ DROPDOWN_SESSION_TYPES = [
13
  ]
14
 
15
  # Load in driver names
16
- with open("assets/driver_names.json") as f:
17
- DRIVER_NAMES: list[str] = json.load(f)["drivers"]
18
 
19
- # Load in constructor names
20
- with open("assets/constructors.json") as f:
21
- CONSTRUCTOR_NAMES: list[str] = json.load(f)["constructors"]
22
 
23
- # Variables
24
- CURRENT_YEAR = datetime.datetime.now().year
 
1
  import json
2
  import datetime
3
 
4
+ # Variables
5
+ CURRENT_YEAR = datetime.datetime.now().year
6
+
7
  AVAILABLE_SESSION_TYPES = [
8
  "fp1", "fp2", "fp3", "q", "s", "ss", "sq", "r",
9
  "practice 1", "practice 2", "practice 3", "sprint",
 
16
  ]
17
 
18
  # Load in driver names
19
+ DRIVER_NAMES: list[str] = json.load(open("assets/driver_names.json"))["drivers"]
 
20
 
21
+ # Load in constructor team names
22
+ CONSTRUCTOR_NAMES: list[str] = json.load(open("assets/constructors.json"))["constructors"]
 
23
 
24
+ # Load in driver details
25
+ DRIVER_DETAILS = json.load(open("assets/driver_details_with_summaries.json"))