{ "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 }