{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "provenance": []
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    },
    "language_info": {
      "name": "python"
    }
  },
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "6HnYmKVPSstT",
        "outputId": "7f0f69a5-15e4-46dd-80e3-b8ae75487004"
      },
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Collecting fastf1\n",
            "  Downloading fastf1-3.8.3-py3-none-any.whl.metadata (5.1 kB)\n",
            "Requirement already satisfied: cryptography in /usr/local/lib/python3.13/dist-packages (from fastf1) (50.0.1)\n",
            "Requirement already satisfied: matplotlib<4.0.0,>=3.8.0 in /usr/local/lib/python3.13/dist-packages (from fastf1) (3.10.0)\n",
            "Requirement already satisfied: numpy<3.0.0,>=1.26.0 in /usr/local/lib/python3.13/dist-packages (from fastf1) (2.1.3)\n",
            "Requirement already satisfied: pandas<3.0.0,>=2.1.1 in /usr/local/lib/python3.13/dist-packages (from fastf1) (2.2.3)\n",
            "Requirement already satisfied: platformdirs in /usr/local/lib/python3.13/dist-packages (from fastf1) (4.11.7)\n",
            "Requirement already satisfied: pydantic in /usr/local/lib/python3.13/dist-packages (from fastf1) (2.13.5)\n",
            "Requirement already satisfied: pyjwt in /usr/local/lib/python3.13/dist-packages (from fastf1) (2.13.0)\n",
            "Requirement already satisfied: python-dateutil in /usr/local/lib/python3.13/dist-packages (from fastf1) (2.9.0.post0)\n",
            "Collecting rapidfuzz (from fastf1)\n",
            "  Downloading rapidfuzz-3.14.6-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.metadata (12 kB)\n",
            "Collecting requests-cache>=1.0.0 (from fastf1)\n",
            "  Downloading requests_cache-1.3.3-py3-none-any.whl.metadata (9.4 kB)\n",
            "Requirement already satisfied: requests>=2.30.0 in /usr/local/lib/python3.13/dist-packages (from fastf1) (2.32.4)\n",
            "Requirement already satisfied: scipy<2.0.0,>=1.11.0 in /usr/local/lib/python3.13/dist-packages (from fastf1) (1.16.3)\n",
            "Collecting signalrcore (from fastf1)\n",
            "  Downloading signalrcore-1.0.2-py3-none-any.whl.metadata (13 kB)\n",
            "Collecting timple>=0.1.6 (from fastf1)\n",
            "  Downloading timple-0.1.8-py3-none-any.whl.metadata (2.0 kB)\n",
            "Requirement already satisfied: websockets>=10.3 in /usr/local/lib/python3.13/dist-packages (from fastf1) (15.0.1)\n",
            "Requirement already satisfied: contourpy>=1.0.1 in /usr/local/lib/python3.13/dist-packages (from matplotlib<4.0.0,>=3.8.0->fastf1) (1.3.3)\n",
            "Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.13/dist-packages (from matplotlib<4.0.0,>=3.8.0->fastf1) (0.12.1)\n",
            "Requirement already satisfied: fonttools>=4.22.0 in /usr/local/lib/python3.13/dist-packages (from matplotlib<4.0.0,>=3.8.0->fastf1) (4.64.0)\n",
            "Requirement already satisfied: kiwisolver>=1.3.1 in /usr/local/lib/python3.13/dist-packages (from matplotlib<4.0.0,>=3.8.0->fastf1) (1.5.1)\n",
            "Requirement already satisfied: packaging>=20.0 in /usr/local/lib/python3.13/dist-packages (from matplotlib<4.0.0,>=3.8.0->fastf1) (26.3)\n",
            "Requirement already satisfied: pillow>=8 in /usr/local/lib/python3.13/dist-packages (from matplotlib<4.0.0,>=3.8.0->fastf1) (11.3.0)\n",
            "Requirement already satisfied: pyparsing>=2.3.1 in /usr/local/lib/python3.13/dist-packages (from matplotlib<4.0.0,>=3.8.0->fastf1) (3.3.2)\n",
            "Requirement already satisfied: pytz>=2020.1 in /usr/local/lib/python3.13/dist-packages (from pandas<3.0.0,>=2.1.1->fastf1) (2025.2)\n",
            "Requirement already satisfied: tzdata>=2022.7 in /usr/local/lib/python3.13/dist-packages (from pandas<3.0.0,>=2.1.1->fastf1) (2026.3)\n",
            "Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.13/dist-packages (from python-dateutil->fastf1) (1.17.0)\n",
            "Requirement already satisfied: charset_normalizer<4,>=2 in /usr/local/lib/python3.13/dist-packages (from requests>=2.30.0->fastf1) (3.4.9)\n",
            "Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.13/dist-packages (from requests>=2.30.0->fastf1) (3.19)\n",
            "Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.13/dist-packages (from requests>=2.30.0->fastf1) (2.5.0)\n",
            "Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.13/dist-packages (from requests>=2.30.0->fastf1) (2026.7.22)\n",
            "Requirement already satisfied: attrs>=21.2 in /usr/local/lib/python3.13/dist-packages (from requests-cache>=1.0.0->fastf1) (26.1.0)\n",
            "Collecting cattrs>=22.2 (from requests-cache>=1.0.0->fastf1)\n",
            "  Downloading cattrs-26.2.0-py3-none-any.whl.metadata (8.5 kB)\n",
            "Collecting url-normalize>=2.0 (from requests-cache>=1.0.0->fastf1)\n",
            "  Downloading url_normalize-3.0.0-py3-none-any.whl.metadata (7.5 kB)\n",
            "Requirement already satisfied: cffi>=2.0.0 in /usr/local/lib/python3.13/dist-packages (from cryptography->fastf1) (2.1.1)\n",
            "Requirement already satisfied: annotated-types>=0.6.0 in /usr/local/lib/python3.13/dist-packages (from pydantic->fastf1) (0.8.0)\n",
            "Requirement already satisfied: pydantic-core==2.46.5 in /usr/local/lib/python3.13/dist-packages (from pydantic->fastf1) (2.46.5)\n",
            "Requirement already satisfied: typing-extensions>=4.14.1 in /usr/local/lib/python3.13/dist-packages (from pydantic->fastf1) (4.16.0)\n",
            "Requirement already satisfied: typing-inspection>=0.4.2 in /usr/local/lib/python3.13/dist-packages (from pydantic->fastf1) (0.4.4)\n",
            "Collecting msgpack==1.1.2 (from signalrcore->fastf1)\n",
            "  Downloading msgpack-1.1.2-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.metadata (8.1 kB)\n",
            "Requirement already satisfied: pycparser in /usr/local/lib/python3.13/dist-packages (from cffi>=2.0.0->cryptography->fastf1) (3.0)\n",
            "Downloading fastf1-3.8.3-py3-none-any.whl (135 kB)\n",
            "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m136.0/136.0 kB\u001b[0m \u001b[31m3.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[?25hDownloading requests_cache-1.3.3-py3-none-any.whl (70 kB)\n",
            "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m70.8/70.8 kB\u001b[0m \u001b[31m4.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[?25hDownloading timple-0.1.8-py3-none-any.whl (17 kB)\n",
            "Downloading rapidfuzz-3.14.6-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (3.2 MB)\n",
            "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m3.2/3.2 MB\u001b[0m \u001b[31m41.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[?25hDownloading signalrcore-1.0.2-py3-none-any.whl (55 kB)\n",
            "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m55.6/55.6 kB\u001b[0m \u001b[31m3.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[?25hDownloading msgpack-1.1.2-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (424 kB)\n",
            "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m424.7/424.7 kB\u001b[0m \u001b[31m24.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[?25hDownloading cattrs-26.2.0-py3-none-any.whl (74 kB)\n",
            "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m74.8/74.8 kB\u001b[0m \u001b[31m4.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[?25hDownloading url_normalize-3.0.0-py3-none-any.whl (16 kB)\n",
            "Installing collected packages: url-normalize, rapidfuzz, msgpack, cattrs, signalrcore, requests-cache, timple, fastf1\n",
            "  Attempting uninstall: msgpack\n",
            "    Found existing installation: msgpack 1.2.2\n",
            "    Uninstalling msgpack-1.2.2:\n",
            "      Successfully uninstalled msgpack-1.2.2\n",
            "Successfully installed cattrs-26.2.0 fastf1-3.8.3 msgpack-1.1.2 rapidfuzz-3.14.6 requests-cache-1.3.3 signalrcore-1.0.2 timple-0.1.8 url-normalize-3.0.0\n"
          ]
        }
      ],
      "source": [
        "!pip install fastf1"
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "import fastf1\n",
        "import pandas as pd\n",
        "import os\n",
        "from google.colab import drive"
      ],
      "metadata": {
        "id": "NE4JRzGJXdxs"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "# Mount your Google Drive\n",
        "drive.mount('/content/drive')"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "4I6-swQdY2tA",
        "outputId": "3fceaea8-f435-4a0f-aa03-a99a35fd9c9e"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Mounted at /content/drive\n"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "# Define the directory\n",
        "cache_dir = '/content/drive/MyDrive/f1 data '\n",
        "\n",
        "# Create the folder if it does not exist\n",
        "if not os.path.exists(cache_dir):\n",
        "    os.makedirs(cache_dir)"
      ],
      "metadata": {
        "id": "HifH32vtauno"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "# Enable caching\n",
        "fastf1.Cache.enable_cache(cache_dir)"
      ],
      "metadata": {
        "id": "x9XLgpLibZNF"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "# Pull the 2023 Monaco Grand Prix Race session\n",
        "session = fastf1.get_session(2023, 'Monaco', 'R')"
      ],
      "metadata": {
        "id": "NW-_2eW1dB48"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "# Load the data\n",
        "session.load()"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "MEqxKYZPfA3c",
        "outputId": "b1c827d1-8e81-4528-85d9-02d0cfb81f49"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stderr",
          "text": [
            "core           INFO \tLoading data for Monaco Grand Prix - Race [v3.8.3]\n",
            "INFO:fastf1.fastf1.core:Loading data for Monaco Grand Prix - Race [v3.8.3]\n",
            "req            INFO \tNo cached data found for session_info. Loading data...\n",
            "INFO:fastf1.fastf1.req:No cached data found for session_info. Loading data...\n",
            "_api           INFO \tFetching session info data...\n",
            "INFO:fastf1.api:Fetching session info data...\n",
            "DEBUG:fastf1.api:Falling back to livetiming mirror (https://livetiming-mirror.fastf1.dev)\n",
            "logger      WARNING \tFailed to load session info data!\n",
            "WARNING:fastf1.fastf1.core:Failed to load session info data!\n",
            "DEBUG:fastf1.fastf1.core:Traceback for failure in session info data\n",
            "Traceback (most recent call last):\n",
            "  File \"/usr/local/lib/python3.13/dist-packages/fastf1/logger.py\", line 112, in __wrapped\n",
            "    return func(*args, **kwargs)\n",
            "  File \"/usr/local/lib/python3.13/dist-packages/fastf1/core.py\", line 1452, in _load_session_info\n",
            "    self._session_info = api.session_info(self.api_path,\n",
            "                         ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^\n",
            "                                          livedata=livedata)\n",
            "                                          ^^^^^^^^^^^^^^^^^^\n",
            "  File \"/usr/local/lib/python3.13/dist-packages/fastf1/req.py\", line 459, in _cached_api_request\n",
            "    data = func(api_path, **func_kwargs)\n",
            "  File \"/usr/local/lib/python3.13/dist-packages/fastf1/_api.py\", line 1730, in session_info\n",
            "    raise SessionNotAvailableError(\n",
            "    ...<2 lines>...\n",
            "    )\n",
            "fastf1._api.SessionNotAvailableError: No data for this session! If this session only finished recently, please try again in a few minutes.\n",
            "req            INFO \tNo cached data found for driver_info. Loading data...\n",
            "INFO:fastf1.fastf1.req:No cached data found for driver_info. Loading data...\n",
            "_api           INFO \tFetching driver list...\n",
            "INFO:fastf1.api:Fetching driver list...\n",
            "DEBUG:fastf1.api:Falling back to livetiming mirror (https://livetiming-mirror.fastf1.dev)\n",
            "core        WARNING \tFailed to load extended driver information!\n",
            "WARNING:fastf1.fastf1.core:Failed to load extended driver information!\n",
            "DEBUG:fastf1.fastf1.core:Exception while loading driver list\n",
            "Traceback (most recent call last):\n",
            "  File \"/usr/local/lib/python3.13/dist-packages/fastf1/core.py\", line 2459, in _drivers_from_f1_api\n",
            "    f1di = api.driver_info(self.api_path, livedata=livedata)\n",
            "  File \"/usr/local/lib/python3.13/dist-packages/fastf1/req.py\", line 459, in _cached_api_request\n",
            "    data = func(api_path, **func_kwargs)\n",
            "  File \"/usr/local/lib/python3.13/dist-packages/fastf1/_api.py\", line 1564, in driver_info\n",
            "    raise SessionNotAvailableError(\n",
            "    ...<2 lines>...\n",
            "    )\n",
            "fastf1._api.SessionNotAvailableError: No data for this session! If this session only finished recently, please try again in a few minutes.\n",
            "req            INFO \tNo cached data found for session_status_data. Loading data...\n",
            "INFO:fastf1.fastf1.req:No cached data found for session_status_data. Loading data...\n",
            "_api           INFO \tFetching session status data...\n",
            "INFO:fastf1.api:Fetching session status data...\n",
            "DEBUG:fastf1.api:Falling back to livetiming mirror (https://livetiming-mirror.fastf1.dev)\n",
            "logger      WARNING \tFailed to load session status data!\n",
            "WARNING:fastf1.fastf1.core:Failed to load session status data!\n",
            "DEBUG:fastf1.fastf1.core:Traceback for failure in session status data\n",
            "Traceback (most recent call last):\n",
            "  File \"/usr/local/lib/python3.13/dist-packages/fastf1/logger.py\", line 112, in __wrapped\n",
            "    return func(*args, **kwargs)\n",
            "  File \"/usr/local/lib/python3.13/dist-packages/fastf1/core.py\", line 2136, in _load_session_status_data\n",
            "    session_status = api.session_status_data(self.api_path,\n",
            "                                             livedata=livedata)\n",
            "  File \"/usr/local/lib/python3.13/dist-packages/fastf1/req.py\", line 459, in _cached_api_request\n",
            "    data = func(api_path, **func_kwargs)\n",
            "  File \"/usr/local/lib/python3.13/dist-packages/fastf1/_api.py\", line 1362, in session_status_data\n",
            "    raise SessionNotAvailableError(\n",
            "    ...<2 lines>...\n",
            "    )\n",
            "fastf1._api.SessionNotAvailableError: No data for this session! If this session only finished recently, please try again in a few minutes.\n",
            "req            INFO \tNo cached data found for lap_count. Loading data...\n",
            "INFO:fastf1.fastf1.req:No cached data found for lap_count. Loading data...\n",
            "_api           INFO \tFetching lap count data...\n",
            "INFO:fastf1.api:Fetching lap count data...\n",
            "DEBUG:fastf1.api:Falling back to livetiming mirror (https://livetiming-mirror.fastf1.dev)\n",
            "logger      WARNING \tFailed to load total lap count!\n",
            "WARNING:fastf1.fastf1.core:Failed to load total lap count!\n",
            "DEBUG:fastf1.fastf1.core:Traceback for failure in total lap count\n",
            "Traceback (most recent call last):\n",
            "  File \"/usr/local/lib/python3.13/dist-packages/fastf1/logger.py\", line 112, in __wrapped\n",
            "    return func(*args, **kwargs)\n",
            "  File \"/usr/local/lib/python3.13/dist-packages/fastf1/core.py\", line 2118, in _load_total_lap_count\n",
            "    lap_count = api.lap_count(self.api_path, livedata=livedata)\n",
            "  File \"/usr/local/lib/python3.13/dist-packages/fastf1/req.py\", line 459, in _cached_api_request\n",
            "    data = func(api_path, **func_kwargs)\n",
            "  File \"/usr/local/lib/python3.13/dist-packages/fastf1/_api.py\", line 1505, in lap_count\n",
            "    raise SessionNotAvailableError(\n",
            "    ...<2 lines>...\n",
            "    )\n",
            "fastf1._api.SessionNotAvailableError: No data for this session! If this session only finished recently, please try again in a few minutes.\n",
            "req            INFO \tNo cached data found for track_status_data. Loading data...\n",
            "INFO:fastf1.fastf1.req:No cached data found for track_status_data. Loading data...\n",
            "_api           INFO \tFetching track status data...\n",
            "INFO:fastf1.api:Fetching track status data...\n",
            "DEBUG:fastf1.api:Falling back to livetiming mirror (https://livetiming-mirror.fastf1.dev)\n",
            "logger      WARNING \tFailed to load track status data!\n",
            "WARNING:fastf1.fastf1.core:Failed to load track status data!\n",
            "DEBUG:fastf1.fastf1.core:Traceback for failure in track status data\n",
            "Traceback (most recent call last):\n",
            "  File \"/usr/local/lib/python3.13/dist-packages/fastf1/logger.py\", line 112, in __wrapped\n",
            "    return func(*args, **kwargs)\n",
            "  File \"/usr/local/lib/python3.13/dist-packages/fastf1/core.py\", line 2105, in _load_track_status_data\n",
            "    track_status = api.track_status_data(self.api_path, livedata=livedata)\n",
            "  File \"/usr/local/lib/python3.13/dist-packages/fastf1/req.py\", line 459, in _cached_api_request\n",
            "    data = func(api_path, **func_kwargs)\n",
            "  File \"/usr/local/lib/python3.13/dist-packages/fastf1/_api.py\", line 1306, in track_status_data\n",
            "    raise SessionNotAvailableError(\n",
            "    ...<2 lines>...\n",
            "    )\n",
            "fastf1._api.SessionNotAvailableError: No data for this session! If this session only finished recently, please try again in a few minutes.\n",
            "req            INFO \tNo cached data found for _extended_timing_data. Loading data...\n",
            "INFO:fastf1.fastf1.req:No cached data found for _extended_timing_data. Loading data...\n",
            "_api           INFO \tFetching timing data...\n",
            "INFO:fastf1.api:Fetching timing data...\n",
            "DEBUG:fastf1.api:Falling back to livetiming mirror (https://livetiming-mirror.fastf1.dev)\n",
            "logger      WARNING \tFailed to load timing data!\n",
            "WARNING:fastf1.fastf1.core:Failed to load timing data!\n",
            "DEBUG:fastf1.fastf1.core:Traceback for failure in lap timing data\n",
            "Traceback (most recent call last):\n",
            "  File \"/usr/local/lib/python3.13/dist-packages/fastf1/logger.py\", line 112, in __wrapped\n",
            "    return func(*args, **kwargs)\n",
            "  File \"/usr/local/lib/python3.13/dist-packages/fastf1/core.py\", line 1458, in _load_laps_data\n",
            "    = api._extended_timing_data(self.api_path, livedata=livedata)\n",
            "      ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n",
            "  File \"/usr/local/lib/python3.13/dist-packages/fastf1/req.py\", line 459, in _cached_api_request\n",
            "    data = func(api_path, **func_kwargs)\n",
            "  File \"/usr/local/lib/python3.13/dist-packages/fastf1/_api.py\", line 201, in _extended_timing_data\n",
            "    raise SessionNotAvailableError(\n",
            "    ...<2 lines>...\n",
            "    )\n",
            "fastf1._api.SessionNotAvailableError: No data for this session! If this session only finished recently, please try again in a few minutes.\n",
            "DEBUG:fastf1.fastf1.core:Failed to add first lap time for driver '1'\n",
            "Traceback (most recent call last):\n",
            "  File \"/usr/local/lib/python3.13/dist-packages/fastf1/core.py\", line 2088, in _add_first_lap_time_from_ergast\n",
            "    self._laps.loc[\n",
            "    ^^^^^^^^^^\n",
            "AttributeError: 'Session' object has no attribute '_laps'. Did you mean: 'laps'?\n",
            "DEBUG:fastf1.fastf1.core:Failed to add first lap time for driver '14'\n",
            "Traceback (most recent call last):\n",
            "  File \"/usr/local/lib/python3.13/dist-packages/fastf1/core.py\", line 2088, in _add_first_lap_time_from_ergast\n",
            "    self._laps.loc[\n",
            "    ^^^^^^^^^^\n",
            "AttributeError: 'Session' object has no attribute '_laps'. Did you mean: 'laps'?\n",
            "DEBUG:fastf1.fastf1.core:Failed to add first lap time for driver '31'\n",
            "Traceback (most recent call last):\n",
            "  File \"/usr/local/lib/python3.13/dist-packages/fastf1/core.py\", line 2088, in _add_first_lap_time_from_ergast\n",
            "    self._laps.loc[\n",
            "    ^^^^^^^^^^\n",
            "AttributeError: 'Session' object has no attribute '_laps'. Did you mean: 'laps'?\n",
            "DEBUG:fastf1.fastf1.core:Failed to add first lap time for driver '55'\n",
            "Traceback (most recent call last):\n",
            "  File \"/usr/local/lib/python3.13/dist-packages/fastf1/core.py\", line 2088, in _add_first_lap_time_from_ergast\n",
            "    self._laps.loc[\n",
            "    ^^^^^^^^^^\n",
            "AttributeError: 'Session' object has no attribute '_laps'. Did you mean: 'laps'?\n",
            "DEBUG:fastf1.fastf1.core:Failed to add first lap time for driver '44'\n",
            "Traceback (most recent call last):\n",
            "  File \"/usr/local/lib/python3.13/dist-packages/fastf1/core.py\", line 2088, in _add_first_lap_time_from_ergast\n",
            "    self._laps.loc[\n",
            "    ^^^^^^^^^^\n",
            "AttributeError: 'Session' object has no attribute '_laps'. Did you mean: 'laps'?\n",
            "DEBUG:fastf1.fastf1.core:Failed to add first lap time for driver '16'\n",
            "Traceback (most recent call last):\n",
            "  File \"/usr/local/lib/python3.13/dist-packages/fastf1/core.py\", line 2088, in _add_first_lap_time_from_ergast\n",
            "    self._laps.loc[\n",
            "    ^^^^^^^^^^\n",
            "AttributeError: 'Session' object has no attribute '_laps'. Did you mean: 'laps'?\n",
            "DEBUG:fastf1.fastf1.core:Failed to add first lap time for driver '10'\n",
            "Traceback (most recent call last):\n",
            "  File \"/usr/local/lib/python3.13/dist-packages/fastf1/core.py\", line 2088, in _add_first_lap_time_from_ergast\n",
            "    self._laps.loc[\n",
            "    ^^^^^^^^^^\n",
            "AttributeError: 'Session' object has no attribute '_laps'. Did you mean: 'laps'?\n",
            "DEBUG:fastf1.fastf1.core:Failed to add first lap time for driver '63'\n",
            "Traceback (most recent call last):\n",
            "  File \"/usr/local/lib/python3.13/dist-packages/fastf1/core.py\", line 2088, in _add_first_lap_time_from_ergast\n",
            "    self._laps.loc[\n",
            "    ^^^^^^^^^^\n",
            "AttributeError: 'Session' object has no attribute '_laps'. Did you mean: 'laps'?\n",
            "DEBUG:fastf1.fastf1.core:Failed to add first lap time for driver '22'\n",
            "Traceback (most recent call last):\n",
            "  File \"/usr/local/lib/python3.13/dist-packages/fastf1/core.py\", line 2088, in _add_first_lap_time_from_ergast\n",
            "    self._laps.loc[\n",
            "    ^^^^^^^^^^\n",
            "AttributeError: 'Session' object has no attribute '_laps'. Did you mean: 'laps'?\n",
            "DEBUG:fastf1.fastf1.core:Failed to add first lap time for driver '4'\n",
            "Traceback (most recent call last):\n",
            "  File \"/usr/local/lib/python3.13/dist-packages/fastf1/core.py\", line 2088, in _add_first_lap_time_from_ergast\n",
            "    self._laps.loc[\n",
            "    ^^^^^^^^^^\n",
            "AttributeError: 'Session' object has no attribute '_laps'. Did you mean: 'laps'?\n",
            "DEBUG:fastf1.fastf1.core:Failed to add first lap time for driver '81'\n",
            "Traceback (most recent call last):\n",
            "  File \"/usr/local/lib/python3.13/dist-packages/fastf1/core.py\", line 2088, in _add_first_lap_time_from_ergast\n",
            "    self._laps.loc[\n",
            "    ^^^^^^^^^^\n",
            "AttributeError: 'Session' object has no attribute '_laps'. Did you mean: 'laps'?\n",
            "DEBUG:fastf1.fastf1.core:Failed to add first lap time for driver '21'\n",
            "Traceback (most recent call last):\n",
            "  File \"/usr/local/lib/python3.13/dist-packages/fastf1/core.py\", line 2088, in _add_first_lap_time_from_ergast\n",
            "    self._laps.loc[\n",
            "    ^^^^^^^^^^\n",
            "AttributeError: 'Session' object has no attribute '_laps'. Did you mean: 'laps'?\n",
            "DEBUG:fastf1.fastf1.core:Failed to add first lap time for driver '23'\n",
            "Traceback (most recent call last):\n",
            "  File \"/usr/local/lib/python3.13/dist-packages/fastf1/core.py\", line 2088, in _add_first_lap_time_from_ergast\n",
            "    self._laps.loc[\n",
            "    ^^^^^^^^^^\n",
            "AttributeError: 'Session' object has no attribute '_laps'. Did you mean: 'laps'?\n",
            "DEBUG:fastf1.fastf1.core:Failed to add first lap time for driver '77'\n",
            "Traceback (most recent call last):\n",
            "  File \"/usr/local/lib/python3.13/dist-packages/fastf1/core.py\", line 2088, in _add_first_lap_time_from_ergast\n",
            "    self._laps.loc[\n",
            "    ^^^^^^^^^^\n",
            "AttributeError: 'Session' object has no attribute '_laps'. Did you mean: 'laps'?\n",
            "DEBUG:fastf1.fastf1.core:Failed to add first lap time for driver '2'\n",
            "Traceback (most recent call last):\n",
            "  File \"/usr/local/lib/python3.13/dist-packages/fastf1/core.py\", line 2088, in _add_first_lap_time_from_ergast\n",
            "    self._laps.loc[\n",
            "    ^^^^^^^^^^\n",
            "AttributeError: 'Session' object has no attribute '_laps'. Did you mean: 'laps'?\n",
            "DEBUG:fastf1.fastf1.core:Failed to add first lap time for driver '20'\n",
            "Traceback (most recent call last):\n",
            "  File \"/usr/local/lib/python3.13/dist-packages/fastf1/core.py\", line 2088, in _add_first_lap_time_from_ergast\n",
            "    self._laps.loc[\n",
            "    ^^^^^^^^^^\n",
            "AttributeError: 'Session' object has no attribute '_laps'. Did you mean: 'laps'?\n",
            "DEBUG:fastf1.fastf1.core:Failed to add first lap time for driver '18'\n",
            "Traceback (most recent call last):\n",
            "  File \"/usr/local/lib/python3.13/dist-packages/fastf1/core.py\", line 2088, in _add_first_lap_time_from_ergast\n",
            "    self._laps.loc[\n",
            "    ^^^^^^^^^^\n",
            "AttributeError: 'Session' object has no attribute '_laps'. Did you mean: 'laps'?\n",
            "DEBUG:fastf1.fastf1.core:Failed to add first lap time for driver '11'\n",
            "Traceback (most recent call last):\n",
            "  File \"/usr/local/lib/python3.13/dist-packages/fastf1/core.py\", line 2088, in _add_first_lap_time_from_ergast\n",
            "    self._laps.loc[\n",
            "    ^^^^^^^^^^\n",
            "AttributeError: 'Session' object has no attribute '_laps'. Did you mean: 'laps'?\n",
            "DEBUG:fastf1.fastf1.core:Failed to add first lap time for driver '24'\n",
            "Traceback (most recent call last):\n",
            "  File \"/usr/local/lib/python3.13/dist-packages/fastf1/core.py\", line 2088, in _add_first_lap_time_from_ergast\n",
            "    self._laps.loc[\n",
            "    ^^^^^^^^^^\n",
            "AttributeError: 'Session' object has no attribute '_laps'. Did you mean: 'laps'?\n",
            "DEBUG:fastf1.fastf1.core:Failed to add first lap time for driver '27'\n",
            "Traceback (most recent call last):\n",
            "  File \"/usr/local/lib/python3.13/dist-packages/fastf1/core.py\", line 2088, in _add_first_lap_time_from_ergast\n",
            "    self._laps.loc[\n",
            "    ^^^^^^^^^^\n",
            "AttributeError: 'Session' object has no attribute '_laps'. Did you mean: 'laps'?\n",
            "core        WARNING \tFailed to add first lap time from Ergast for drivers: ['1', '14', '31', '55', '44', '16', '10', '63', '22', '4', '81', '21', '23', '77', '2', '20', '18', '11', '24', '27']\n",
            "WARNING:fastf1.fastf1.core:Failed to add first lap time from Ergast for drivers: ['1', '14', '31', '55', '44', '16', '10', '63', '22', '4', '81', '21', '23', '77', '2', '20', '18', '11', '24', '27']\n",
            "req            INFO \tNo cached data found for car_data. Loading data...\n",
            "INFO:fastf1.fastf1.req:No cached data found for car_data. Loading data...\n",
            "_api           INFO \tFetching car data...\n",
            "INFO:fastf1.api:Fetching car data...\n",
            "DEBUG:fastf1.api:Falling back to livetiming mirror (https://livetiming-mirror.fastf1.dev)\n",
            "core        WARNING \tCar telemetry data is unavailable!\n",
            "WARNING:fastf1.fastf1.core:Car telemetry data is unavailable!\n",
            "req            INFO \tNo cached data found for position_data. Loading data...\n",
            "INFO:fastf1.fastf1.req:No cached data found for position_data. Loading data...\n",
            "_api           INFO \tFetching position data...\n",
            "INFO:fastf1.api:Fetching position data...\n",
            "DEBUG:fastf1.api:Falling back to livetiming mirror (https://livetiming-mirror.fastf1.dev)\n",
            "core        WARNING \tCar position data is unavailable!\n",
            "WARNING:fastf1.fastf1.core:Car position data is unavailable!\n",
            "core        WARNING \tFailed to determine `Session.t0_date`!\n",
            "WARNING:fastf1.fastf1.core:Failed to determine `Session.t0_date`!\n",
            "req            INFO \tNo cached data found for weather_data. Loading data...\n",
            "INFO:fastf1.fastf1.req:No cached data found for weather_data. Loading data...\n",
            "_api           INFO \tFetching weather data...\n",
            "INFO:fastf1.api:Fetching weather data...\n",
            "DEBUG:fastf1.api:Falling back to livetiming mirror (https://livetiming-mirror.fastf1.dev)\n",
            "logger      WARNING \tFailed to load weather data!\n",
            "WARNING:fastf1.fastf1.core:Failed to load weather data!\n",
            "DEBUG:fastf1.fastf1.core:Traceback for failure in weather data\n",
            "Traceback (most recent call last):\n",
            "  File \"/usr/local/lib/python3.13/dist-packages/fastf1/logger.py\", line 112, in __wrapped\n",
            "    return func(*args, **kwargs)\n",
            "  File \"/usr/local/lib/python3.13/dist-packages/fastf1/core.py\", line 2611, in _load_weather_data\n",
            "    weather_data = api.weather_data(self.api_path, livedata=livedata)\n",
            "  File \"/usr/local/lib/python3.13/dist-packages/fastf1/req.py\", line 459, in _cached_api_request\n",
            "    data = func(api_path, **func_kwargs)\n",
            "  File \"/usr/local/lib/python3.13/dist-packages/fastf1/_api.py\", line 1656, in weather_data\n",
            "    raise SessionNotAvailableError(\n",
            "    ...<2 lines>...\n",
            "    )\n",
            "fastf1._api.SessionNotAvailableError: No data for this session! If this session only finished recently, please try again in a few minutes.\n",
            "req            INFO \tNo cached data found for race_control_messages. Loading data...\n",
            "INFO:fastf1.fastf1.req:No cached data found for race_control_messages. Loading data...\n",
            "_api           INFO \tFetching race control messages...\n",
            "INFO:fastf1.api:Fetching race control messages...\n",
            "DEBUG:fastf1.api:Falling back to livetiming mirror (https://livetiming-mirror.fastf1.dev)\n",
            "logger      WARNING \tFailed to load race control messages!\n",
            "WARNING:fastf1.fastf1.core:Failed to load race control messages!\n",
            "DEBUG:fastf1.fastf1.core:Traceback for failure in race control messages\n",
            "Traceback (most recent call last):\n",
            "  File \"/usr/local/lib/python3.13/dist-packages/fastf1/logger.py\", line 112, in __wrapped\n",
            "    return func(*args, **kwargs)\n",
            "  File \"/usr/local/lib/python3.13/dist-packages/fastf1/core.py\", line 2618, in _load_race_control_messages\n",
            "    race_control_messages = api.race_control_messages(self.api_path,\n",
            "                                                      livedata=livedata)\n",
            "  File \"/usr/local/lib/python3.13/dist-packages/fastf1/req.py\", line 459, in _cached_api_request\n",
            "    data = func(api_path, **func_kwargs)\n",
            "  File \"/usr/local/lib/python3.13/dist-packages/fastf1/_api.py\", line 1433, in race_control_messages\n",
            "    raise SessionNotAvailableError(\n",
            "    ...<2 lines>...\n",
            "    )\n",
            "fastf1._api.SessionNotAvailableError: No data for this session! If this session only finished recently, please try again in a few minutes.\n",
            "core           INFO \tFinished loading data for 20 drivers: ['1', '14', '31', '44', '63', '16', '10', '55', '4', '81', '77', '21', '24', '23', '22', '11', '27', '2', '20', '18']\n",
            "INFO:fastf1.fastf1.core:Finished loading data for 20 drivers: ['1', '14', '31', '44', '63', '16', '10', '55', '4', '81', '77', '21', '24', '23', '22', '11', '27', '2', '20', '18']\n"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "# Look at the final race classification results using Pandas\n",
        "results_df = session.results\n",
        "print(results_df[['Abbreviation', 'TeamName', 'Position', 'Time', 'Status']].head())"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "_CI7lkiigGNR",
        "outputId": "9ec04d94-a2ba-48d4-e069-99c8460d04ba"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "             Abbreviation        TeamName  Position                   Time  \\\n",
            "DriverNumber                                                                 \n",
            "1                     VER        Red Bull       1.0 0 days 01:48:51.980000   \n",
            "14                    ALO    Aston Martin       2.0 0 days 00:00:27.921000   \n",
            "31                    OCO  Alpine F1 Team       3.0 0 days 00:00:36.990000   \n",
            "44                    HAM        Mercedes       4.0 0 days 00:00:39.062000   \n",
            "63                    RUS        Mercedes       5.0 0 days 00:00:56.284000   \n",
            "\n",
            "                Status  \n",
            "DriverNumber            \n",
            "1             Finished  \n",
            "14            Finished  \n",
            "31            Finished  \n",
            "44            Finished  \n",
            "63            Finished  \n"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "export_path = f'{cache_dir}/monaco_2023_results.csv'"
      ],
      "metadata": {
        "id": "J_aPsRKEmImJ"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "results_df.to_csv(export_path, index=False)"
      ],
      "metadata": {
        "id": "fYsRN8qhmbix"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "print(f\"Data successfully exported to: {export_path}\")"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "AhvR85m6qnvw",
        "outputId": "98da5d8a-6cc3-4ad6-a793-3f99916353ab"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Data successfully exported to: /content/drive/MyDrive/f1 data /monaco_2023_results.csv\n"
          ]
        }
      ]
    }
  ]
}