File size: 22,763 Bytes
81c6a41 28cd974 81c6a41 28cd974 81c6a41 0f5d5f3 28cd974 0f5d5f3 28cd974 0f5d5f3 28cd974 0f5d5f3 89c9126 28cd974 4d56b75 28cd974 4d56b75 28cd974 c6542ed 89c9126 c6542ed 89c9126 6269c32 c6542ed 6269c32 c6542ed 97a44d4 89c9126 c6542ed 89c9126 97a44d4 89c9126 6269c32 c6542ed 6269c32 81c6a41 89c9126 81c6a41 89c9126 81c6a41 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 |
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "b7d2515e",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Successfully loaded in libraries\n"
]
}
],
"source": [
"import fastf1\n",
"from pprint import pprint"
]
},
{
"cell_type": "markdown",
"id": "81c06a3f",
"metadata": {},
"source": [
"# FastF1"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "2a205292",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"req WARNING \tDEFAULT CACHE ENABLED! (942.29 MB) /home/arre/.cache/fastf1\n",
"core INFO \tLoading data for Australian Grand Prix - Race [v3.5.3]\n",
"req INFO \tUsing cached data for session_info\n",
"req INFO \tUsing cached data for driver_info\n",
"req INFO \tUsing cached data for session_status_data\n",
"req INFO \tUsing cached data for lap_count\n",
"req INFO \tUsing cached data for track_status_data\n",
"req INFO \tUsing cached data for _extended_timing_data\n",
"req INFO \tUsing cached data for timing_app_data\n",
"core INFO \tProcessing timing data...\n",
"req INFO \tUsing cached data for car_data\n",
"req INFO \tUsing cached data for position_data\n",
"req INFO \tUsing cached data for weather_data\n",
"req INFO \tUsing cached data for race_control_messages\n",
"core WARNING \tDriver 4 completed the race distance 00:00.022000 before the recorded end of the session.\n",
"core INFO \tFinished loading data for 20 drivers: ['4', '1', '63', '12', '23', '18', '27', '16', '81', '44', '10', '22', '31', '87', '30', '5', '14', '55', '7', '6']\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Index(['Time', 'Driver', 'DriverNumber', 'LapTime', 'LapNumber', 'Stint',\n",
" 'PitOutTime', 'PitInTime', 'Sector1Time', 'Sector2Time', 'Sector3Time',\n",
" 'Sector1SessionTime', 'Sector2SessionTime', 'Sector3SessionTime',\n",
" 'SpeedI1', 'SpeedI2', 'SpeedFL', 'SpeedST', 'IsPersonalBest',\n",
" 'Compound', 'TyreLife', 'FreshTyre', 'Team', 'LapStartTime',\n",
" 'LapStartDate', 'TrackStatus', 'Position', 'Deleted', 'DeletedReason',\n",
" 'FastF1Generated', 'IsAccurate'],\n",
" dtype='object')\n",
" Driver DriverNumber Team\n",
"0 VER 1 Red Bull Racing\n",
"1 VER 1 Red Bull Racing\n",
"2 VER 1 Red Bull Racing\n",
"3 VER 1 Red Bull Racing\n",
"4 VER 1 Red Bull Racing\n",
".. ... ... ...\n",
"922 BEA 87 Haas F1 Team\n",
"923 BEA 87 Haas F1 Team\n",
"924 BEA 87 Haas F1 Team\n",
"925 BEA 87 Haas F1 Team\n",
"926 BEA 87 Haas F1 Team\n",
"\n",
"[927 rows x 3 columns]\n"
]
}
],
"source": [
"session = fastf1.get_session(2025, 1, \"race\")\n",
"session.load()\n",
"print(session.laps.columns)\n",
"print(session.laps[[\"Driver\", \"DriverNumber\", \"Team\"]])"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "44f7516f",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Time 0 days 02:28:03.586000\n",
"Driver NOR\n",
"DriverNumber 4\n",
"LapTime 0 days 00:01:22.167000\n",
"LapNumber 43.0\n",
"Stint 5.0\n",
"PitOutTime NaT\n",
"PitInTime NaT\n",
"Sector1Time 0 days 00:00:28.553000\n",
"Sector2Time 0 days 00:00:18.537000\n",
"Sector3Time 0 days 00:00:35.077000\n",
"Sector1SessionTime 0 days 02:27:10.030000\n",
"Sector2SessionTime 0 days 02:27:28.567000\n",
"Sector3SessionTime 0 days 02:28:03.644000\n",
"SpeedI1 271.0\n",
"SpeedI2 290.0\n",
"SpeedFL 292.0\n",
"SpeedST 300.0\n",
"IsPersonalBest True\n",
"Compound HARD\n",
"TyreLife 10.0\n",
"FreshTyre False\n",
"Team McLaren\n",
"LapStartTime 0 days 02:26:41.419000\n",
"LapStartDate 2025-03-16 05:34:04.038000\n",
"TrackStatus 1\n",
"Position 1.0\n",
"Deleted False\n",
"DeletedReason \n",
"FastF1Generated False\n",
"IsAccurate True\n",
"Name: 635, dtype: object\n"
]
}
],
"source": [
"print(session.laps.pick_fastest())"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "62bf0598",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" position positionText points wins driverId driverNumber \\\n",
"0 1 1 186.0 5 piastri 81 \n",
"1 2 2 176.0 2 norris 4 \n",
"2 3 3 137.0 2 max_verstappen 33 \n",
"3 4 4 111.0 0 russell 63 \n",
"4 5 5 94.0 0 leclerc 16 \n",
"5 6 6 71.0 0 hamilton 44 \n",
"6 7 7 48.0 0 antonelli 12 \n",
"7 8 8 42.0 0 albon 23 \n",
"8 9 9 21.0 0 hadjar 6 \n",
"9 10 10 20.0 0 ocon 31 \n",
"10 11 11 16.0 0 hulkenberg 27 \n",
"11 12 12 14.0 0 stroll 18 \n",
"12 13 13 12.0 0 sainz 55 \n",
"13 14 14 11.0 0 gasly 10 \n",
"14 15 15 10.0 0 tsunoda 22 \n",
"15 16 16 6.0 0 bearman 87 \n",
"16 17 17 4.0 0 lawson 30 \n",
"17 18 18 2.0 0 alonso 14 \n",
"18 19 19 0.0 0 bortoleto 5 \n",
"19 20 20 0.0 0 doohan 7 \n",
"20 21 21 0.0 0 colapinto 43 \n",
"\n",
" driverCode driverUrl givenName \\\n",
"0 PIA http://en.wikipedia.org/wiki/Oscar_Piastri Oscar \n",
"1 NOR http://en.wikipedia.org/wiki/Lando_Norris Lando \n",
"2 VER http://en.wikipedia.org/wiki/Max_Verstappen Max \n",
"3 RUS http://en.wikipedia.org/wiki/George_Russell_(r... George \n",
"4 LEC http://en.wikipedia.org/wiki/Charles_Leclerc Charles \n",
"5 HAM http://en.wikipedia.org/wiki/Lewis_Hamilton Lewis \n",
"6 ANT https://en.wikipedia.org/wiki/Andrea_Kimi_Anto... Andrea Kimi \n",
"7 ALB http://en.wikipedia.org/wiki/Alexander_Albon Alexander \n",
"8 HAD https://en.wikipedia.org/wiki/Isack_Hadjar Isack \n",
"9 OCO http://en.wikipedia.org/wiki/Esteban_Ocon Esteban \n",
"10 HUL http://en.wikipedia.org/wiki/Nico_H%C3%BClkenberg Nico \n",
"11 STR http://en.wikipedia.org/wiki/Lance_Stroll Lance \n",
"12 SAI http://en.wikipedia.org/wiki/Carlos_Sainz_Jr. Carlos \n",
"13 GAS http://en.wikipedia.org/wiki/Pierre_Gasly Pierre \n",
"14 TSU http://en.wikipedia.org/wiki/Yuki_Tsunoda Yuki \n",
"15 BEA http://en.wikipedia.org/wiki/Oliver_Bearman Oliver \n",
"16 LAW http://en.wikipedia.org/wiki/Liam_Lawson Liam \n",
"17 ALO http://en.wikipedia.org/wiki/Fernando_Alonso Fernando \n",
"18 BOR https://en.wikipedia.org/wiki/Gabriel_Bortoleto Gabriel \n",
"19 DOO http://en.wikipedia.org/wiki/Jack_Doohan Jack \n",
"20 COL http://en.wikipedia.org/wiki/Franco_Colapinto Franco \n",
"\n",
" familyName dateOfBirth driverNationality constructorIds \\\n",
"0 Piastri 2001-04-06 Australian [mclaren] \n",
"1 Norris 1999-11-13 British [mclaren] \n",
"2 Verstappen 1997-09-30 Dutch [red_bull] \n",
"3 Russell 1998-02-15 British [mercedes] \n",
"4 Leclerc 1997-10-16 Monegasque [ferrari] \n",
"5 Hamilton 1985-01-07 British [ferrari] \n",
"6 Antonelli 2006-08-25 Italian [mercedes] \n",
"7 Albon 1996-03-23 Thai [williams] \n",
"8 Hadjar 2004-09-28 French [rb] \n",
"9 Ocon 1996-09-17 French [haas] \n",
"10 Hülkenberg 1987-08-19 German [sauber] \n",
"11 Stroll 1998-10-29 Canadian [aston_martin] \n",
"12 Sainz 1994-09-01 Spanish [williams] \n",
"13 Gasly 1996-02-07 French [alpine] \n",
"14 Tsunoda 2000-05-11 Japanese [rb, red_bull] \n",
"15 Bearman 2005-05-08 British [haas] \n",
"16 Lawson 2002-02-11 New Zealander [red_bull, rb] \n",
"17 Alonso 1981-07-29 Spanish [aston_martin] \n",
"18 Bortoleto 2004-10-14 Brazilian [sauber] \n",
"19 Doohan 2003-01-20 Australian [alpine] \n",
"20 Colapinto 2003-05-27 Argentine [alpine] \n",
"\n",
" constructorUrls constructorNames \\\n",
"0 [http://en.wikipedia.org/wiki/McLaren] [McLaren] \n",
"1 [http://en.wikipedia.org/wiki/McLaren] [McLaren] \n",
"2 [http://en.wikipedia.org/wiki/Red_Bull_Racing] [Red Bull] \n",
"3 [http://en.wikipedia.org/wiki/Mercedes-Benz_in... [Mercedes] \n",
"4 [http://en.wikipedia.org/wiki/Scuderia_Ferrari] [Ferrari] \n",
"5 [http://en.wikipedia.org/wiki/Scuderia_Ferrari] [Ferrari] \n",
"6 [http://en.wikipedia.org/wiki/Mercedes-Benz_in... [Mercedes] \n",
"7 [http://en.wikipedia.org/wiki/Williams_Grand_P... [Williams] \n",
"8 [http://en.wikipedia.org/wiki/RB_Formula_One_T... [RB F1 Team] \n",
"9 [http://en.wikipedia.org/wiki/Haas_F1_Team] [Haas F1 Team] \n",
"10 [http://en.wikipedia.org/wiki/Sauber_Motorsport] [Sauber] \n",
"11 [http://en.wikipedia.org/wiki/Aston_Martin_in_... [Aston Martin] \n",
"12 [http://en.wikipedia.org/wiki/Williams_Grand_P... [Williams] \n",
"13 [http://en.wikipedia.org/wiki/Alpine_F1_Team] [Alpine F1 Team] \n",
"14 [http://en.wikipedia.org/wiki/RB_Formula_One_T... [RB F1 Team, Red Bull] \n",
"15 [http://en.wikipedia.org/wiki/Haas_F1_Team] [Haas F1 Team] \n",
"16 [http://en.wikipedia.org/wiki/Red_Bull_Racing,... [Red Bull, RB F1 Team] \n",
"17 [http://en.wikipedia.org/wiki/Aston_Martin_in_... [Aston Martin] \n",
"18 [http://en.wikipedia.org/wiki/Sauber_Motorsport] [Sauber] \n",
"19 [http://en.wikipedia.org/wiki/Alpine_F1_Team] [Alpine F1 Team] \n",
"20 [http://en.wikipedia.org/wiki/Alpine_F1_Team] [Alpine F1 Team] \n",
"\n",
" constructorNationalities \n",
"0 [British] \n",
"1 [British] \n",
"2 [Austrian] \n",
"3 [German] \n",
"4 [Italian] \n",
"5 [Italian] \n",
"6 [German] \n",
"7 [British] \n",
"8 [Italian] \n",
"9 [American] \n",
"10 [Swiss] \n",
"11 [British] \n",
"12 [British] \n",
"13 [French] \n",
"14 [Italian, Austrian] \n",
"15 [American] \n",
"16 [Austrian, Italian] \n",
"17 [British] \n",
"18 [Swiss] \n",
"19 [French] \n",
"20 [French] \n"
]
}
],
"source": [
"ergast = fastf1.ergast.Ergast()\n",
"driver_standings = ergast.get_driver_standings(2025).content[0]\n",
"print(driver_standings)\n",
"#driver_standing = driver_standings[[\"position\", \"points\", \"wins\", \"driverCode\"]].reset_index(drop=True)\n",
"#driver_standing = driver_standing[driver_standing[\"driverCode\"] == \"HAM\"]"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "bd15c64a",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{'Ferrari',\n",
" 'Force India',\n",
" 'Haas F1 Team',\n",
" 'McLaren',\n",
" 'Mercedes',\n",
" 'Red Bull',\n",
" 'Renault',\n",
" 'Sauber',\n",
" 'Toro Rosso',\n",
" 'Williams'}\n"
]
}
],
"source": [
"ergast = fastf1.ergast.Ergast()\n",
"constructor_standings = ergast.get_constructor_standings(2018).content[0]\n",
"pprint(set(constructor_standings[\"constructorName\"]))\n",
"#constructor_standing = constructor_standings[[\"position\", \"points\", \"wins\", \"constructorName\"]].reset_index(drop=True)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "352270a0",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"core INFO \tLoading data for Japanese Grand Prix - Race [v3.5.3]\n",
"req INFO \tUsing cached data for session_info\n",
"req INFO \tUsing cached data for driver_info\n",
"req INFO \tUsing cached data for session_status_data\n",
"req INFO \tUsing cached data for lap_count\n",
"req INFO \tUsing cached data for track_status_data\n",
"req INFO \tUsing cached data for _extended_timing_data\n",
"req INFO \tUsing cached data for timing_app_data\n",
"core INFO \tProcessing timing data...\n",
"req INFO \tUsing cached data for weather_data\n",
"req INFO \tUsing cached data for race_control_messages\n",
"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",
"data WARNING \tFailed to generate marker distance information: telemetry data has not been loaded\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"CircuitInfo(corners= X Y Number Letter Angle Distance\n",
"0 5954.595977 -6043.797284 1 -359.859187 NaN\n",
"1 5411.746105 -6985.870033 2 -81.205284 NaN\n",
"2 3770.348048 -5370.929541 3 -131.304090 NaN\n",
"3 2554.616588 -4969.478669 4 -304.343564 NaN\n",
"4 1863.122660 -3634.685488 5 -131.398389 NaN\n",
"5 343.857125 -3137.336941 6 -311.879680 NaN\n",
"6 -615.746076 -519.819724 7 -106.459045 NaN\n",
"7 -3936.654450 -2323.145349 8 -57.888888 NaN\n",
"8 -5453.049412 -2538.215879 9 -110.431844 NaN\n",
"9 -6229.209841 449.908978 10 -1.787031 NaN\n",
"10 -5964.645828 1876.742727 11 -126.423013 NaN\n",
"11 -7552.525448 119.000613 12 -237.277364 NaN\n",
"12 -12335.806433 3018.433431 13 -125.951757 NaN\n",
"13 -13731.830146 2733.425582 14 -201.694648 NaN\n",
"14 -4974.205293 -1679.808731 15 -254.712390 NaN\n",
"15 -1819.327067 517.589808 16 -293.925016 NaN\n",
"16 -1184.012753 429.700268 17 -50.270393 NaN\n",
"17 332.706500 616.534453 18 -291.606210 NaN,\n",
" marshal_lights= X Y Number Letter Angle Distance\n",
"0 1690.855950 -638.228799 1 -319.688225 NaN\n",
"1 5783.596809 -5462.065134 2 -326.487422 NaN\n",
"2 4811.098103 -6861.098123 3 -135.071247 NaN\n",
"3 3613.521255 -5257.354862 4 -300.361781 NaN\n",
"4 1815.810860 -3592.898831 5 -297.867821 NaN\n",
"5 198.335929 -2984.219502 6 -140.707699 NaN\n",
"6 298.955074 -1117.388942 7 -335.948534 NaN\n",
"7 -1697.196338 -420.240677 8 -260.369093 NaN\n",
"8 -4279.213479 -2448.991996 9 -80.383553 NaN\n",
"9 -5705.360349 -2278.848846 10 -161.756206 NaN\n",
"10 -6223.720506 612.148266 11 -2.135760 NaN\n",
"11 -6037.625361 1929.727809 12 -295.371985 NaN\n",
"12 -7620.649284 74.874949 13 -58.450233 NaN\n",
"13 -10755.257143 583.334425 14 -126.874237 NaN\n",
"14 -12499.786963 3090.369959 15 -289.937350 NaN\n",
"15 -13787.721653 2369.387645 16 -170.487671 NaN\n",
"16 -12375.140308 938.000955 17 -122.280757 NaN\n",
"17 -10189.779019 -164.943254 18 -109.977438 NaN\n",
"18 -7499.143789 -1076.181403 19 -109.130546 NaN\n",
"19 -4733.288295 -1590.501071 20 -68.544674 NaN\n",
"20 -1984.075069 530.759537 21 -258.330855 NaN\n",
"21 -86.348618 755.041276 22 -284.607743 NaN,\n",
" marshal_sectors= X Y Number Letter Angle Distance\n",
"0 1749.509891 -706.732882 1 -319.461645 NaN\n",
"1 5890.822450 -5655.136054 2 -343.938801 NaN\n",
"2 4982.553266 -6958.944675 3 -107.988939 NaN\n",
"3 3770.348048 -5370.929541 4 -131.463504 NaN\n",
"4 1886.764195 -3655.599156 5 -311.621063 NaN\n",
"5 353.981975 -3146.309291 6 -311.728322 NaN\n",
"6 344.825980 -1220.364548 7 -337.684641 NaN\n",
"7 -1536.171947 -402.081185 8 -268.084725 NaN\n",
"8 -4239.222910 -2442.075986 9 -80.307903 NaN\n",
"9 -5607.722824 -2440.304958 10 -137.786652 NaN\n",
"10 -6229.209841 449.908978 11 -2.314662 NaN\n",
"11 -6082.609487 1931.331580 12 -271.786528 NaN\n",
"12 -7563.880972 111.645273 13 -237.193746 NaN\n",
"13 -10809.400279 623.878159 14 -306.809173 NaN\n",
"14 -12457.333265 3075.178205 15 -289.922395 NaN\n",
"15 -13782.934850 2342.759685 16 -169.348189 NaN\n",
"16 -12386.562623 945.247835 17 -122.394556 NaN\n",
"17 -10177.060736 -169.562715 18 -109.850944 NaN\n",
"18 -7417.936277 -1103.488715 19 -108.299236 NaN\n",
"19 -4779.517092 -1608.478900 20 -68.926520 NaN\n",
"20 -1948.165854 534.110177 21 -85.058804 NaN\n",
"21 53.048886 717.912969 22 -289.674903 NaN,\n",
" rotation=49.0)\n"
]
}
],
"source": [
"session = fastf1.get_session(2025, 3, \"R\")\n",
"session.load(telemetry=False)\n",
"circuit_info = session.get_circuit_info()\n",
"pprint(circuit_info)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "hackaton",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.9"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
|