> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/theOehrly/Fast-F1/llms.txt
> Use this file to discover all available pages before exploring further.

# Laps API

> Reference for FastF1 Laps and Lap classes - access and filter lap timing data

The Laps and Lap classes provide access to lap timing data with filtering and telemetry access.

## Laps

DataFrame-like object for accessing lap timing data of multiple laps.

**Constructor:**

<ParamField path="session" type="Session | None" default="None">
  Instance of Session class (required for full functionality)
</ParamField>

**Available Columns:**

* `Time` (timedelta64\[ns]): Time when the lap was completed
* `Driver` (str): Driver three-letter abbreviation
* `DriverNumber` (str): Driver number
* `LapTime` (timedelta64\[ns]): Lap time duration
* `LapNumber` (float64): Lap number
* `Stint` (float64): Stint number
* `PitOutTime` (timedelta64\[ns]): Time when car exited pit lane
* `PitInTime` (timedelta64\[ns]): Time when car entered pit lane
* `Sector1Time` (timedelta64\[ns]): Sector 1 time
* `Sector2Time` (timedelta64\[ns]): Sector 2 time
* `Sector3Time` (timedelta64\[ns]): Sector 3 time
* `Sector1SessionTime` (timedelta64\[ns]): Session time at sector 1
* `Sector2SessionTime` (timedelta64\[ns]): Session time at sector 2
* `Sector3SessionTime` (timedelta64\[ns]): Session time at sector 3
* `SpeedI1` (float64): Speed trap at intermediate 1 (km/h)
* `SpeedI2` (float64): Speed trap at intermediate 2 (km/h)
* `SpeedFL` (float64): Speed trap at finish line (km/h)
* `SpeedST` (float64): Speed trap at speed trap (km/h)
* `IsPersonalBest` (bool): Whether this lap is the driver's personal best
* `Compound` (str): Tyre compound ('SOFT', 'MEDIUM', 'HARD', 'INTERMEDIATE', 'WET')
* `TyreLife` (float64): Laps completed on this set of tyres
* `FreshTyre` (bool): Whether tyres were new when fitted
* `Team` (str): Team name
* `LapStartTime` (timedelta64\[ns]): Time when the lap started
* `LapStartDate` (datetime64\[ns]): Date when the lap started
* `TrackStatus` (str): Track status flags during the lap
* `Position` (float64): Position at the end of this lap
* `Deleted` (bool): Whether the lap time was deleted
* `DeletedReason` (str): Reason for deletion
* `FastF1Generated` (bool): Whether this lap was generated by FastF1
* `IsAccurate` (bool): Whether the lap passed accuracy validation

***

## Filtering Methods

### pick\_drivers()

Return all laps of the specified driver(s).

<ParamField path="identifiers" type="int | str | Iterable[int | str]" required>
  Driver abbreviation(s) or driver number(s) - can be mixed
</ParamField>

<ResponseField name="return" type="Laps">
  Filtered Laps object
</ResponseField>

**Example:**

```python theme={null}
# Single driver
ver_laps = laps.pick_drivers('VER')
ham_laps = laps.pick_drivers(44)

# Multiple drivers
top_3_laps = laps.pick_drivers(['VER', 'HAM', 'LEC'])
mixed = laps.pick_drivers([1, 'HAM', 44])
```

***

### pick\_teams()

Return all laps of the specified team(s).

<ParamField path="names" type="str | Iterable[str]" required>
  Team name(s)
</ParamField>

<ResponseField name="return" type="Laps">
  Filtered Laps object
</ResponseField>

**Example:**

```python theme={null}
# Single team
rbr_laps = laps.pick_teams('Red Bull Racing')

# Multiple teams
top_teams = laps.pick_teams(['Red Bull Racing', 'Ferrari', 'Mercedes'])
```

***

### pick\_laps()

Return all laps matching specific lap number(s).

<ParamField path="lap_numbers" type="int | Iterable[int]" required>
  Lap number or iterable of lap numbers
</ParamField>

<ResponseField name="return" type="Laps">
  Filtered Laps object
</ResponseField>

**Example:**

```python theme={null}
# Single lap
lap_1 = laps.pick_laps(1)

# Range of laps
laps_10_to_20 = laps.pick_laps(range(10, 21))

# Specific laps
specific = laps.pick_laps([1, 5, 10, 20])
```

***

### pick\_fastest()

Return the lap with the fastest lap time.

<ParamField path="only_by_time" type="bool" default="False">
  If False, only return laps marked as personal best. If True, ignore personal best flag and return the absolute fastest lap.
</ParamField>

<ResponseField name="return" type="Lap | None">
  The fastest Lap object, or None if no valid lap exists
</ResponseField>

**Example:**

```python theme={null}
# Fastest personal best lap
fastest = laps.pick_fastest()

# Absolute fastest lap (even if deleted)
fastest_any = laps.pick_fastest(only_by_time=True)
```

***

### pick\_quicklaps()

Return all laps faster than a threshold (default: 107% of fastest lap).

<ParamField path="threshold" type="float | None" default="None">
  Custom threshold coefficient (e.g., 1.05 for 105%). Defaults to 1.07 (107%).
</ParamField>

<ResponseField name="return" type="Laps">
  Filtered Laps object
</ResponseField>

**Example:**

```python theme={null}
# Use default 107% rule
quick_laps = laps.pick_quicklaps()

# Custom 105% threshold
quick_laps = laps.pick_quicklaps(threshold=1.05)
```

***

### pick\_compounds()

Return all laps done on specific tyre compound(s).

<ParamField path="compounds" type="str | Iterable[str]" required>
  Compound name(s): 'SOFT', 'MEDIUM', 'HARD', 'INTERMEDIATE', 'WET', 'UNKNOWN', 'TEST\_UNKNOWN'
</ParamField>

<ResponseField name="return" type="Laps">
  Filtered Laps object
</ResponseField>

**Example:**

```python theme={null}
# Single compound
soft_laps = laps.pick_compounds('SOFT')

# Multiple compounds (all slicks)
slick_laps = laps.pick_compounds(['SOFT', 'MEDIUM', 'HARD'])
```

***

### pick\_track\_status()

Return all laps set under a specific track status.

<ParamField path="status" type="str" required>
  The track status as a string (e.g., '1' for green flag, '2' for yellow flag, '4' for safety car)
</ParamField>

<ParamField path="how" type="str" default="'equals'">
  Matching method: 'equals', 'contains', 'excludes', 'any', 'none'
</ParamField>

<ResponseField name="return" type="Laps">
  Filtered Laps object
</ResponseField>

**Example:**

```python theme={null}
# Green flag laps only
green_laps = laps.pick_track_status('1', how='equals')

# Any lap with yellow flag
yellow_laps = laps.pick_track_status('2', how='contains')
```

***

### pick\_wo\_box()

Return all laps which are NOT in-laps or out-laps.

<ResponseField name="return" type="Laps">
  Filtered Laps object
</ResponseField>

***

### pick\_box\_laps()

Return in-laps, out-laps, or both.

<ParamField path="which" type="str" default="'both'">
  One of 'in', 'out', or 'both'
</ParamField>

<ResponseField name="return" type="Laps">
  Filtered Laps object
</ResponseField>

***

### pick\_accurate()

Return all laps which pass accuracy validation.

<ResponseField name="return" type="Laps">
  Filtered Laps object
</ResponseField>

***

### pick\_not\_deleted()

Return all laps whose lap times are NOT deleted.

<ResponseField name="return" type="Laps">
  Filtered Laps object
</ResponseField>

***

## Telemetry Methods

### get\_telemetry()

Get telemetry data for all laps in this Laps object.

<ParamField path="frequency" type="int | Literal['original'] | None" default="None">
  Optional frequency to override the default. Either 'original' or an integer for frequency in Hz.
</ParamField>

<ResponseField name="return" type="Telemetry">
  Telemetry object with merged car and position data
</ResponseField>

<Note>
  Laps must contain data from only one driver.
</Note>

***

### get\_car\_data()

Get car data (Speed, RPM, Throttle, etc.) for all laps.

<ResponseField name="return" type="Telemetry">
  Telemetry object with car data only
</ResponseField>

***

### get\_pos\_data()

Get position data (X, Y, Z coordinates) for all laps.

<ResponseField name="return" type="Telemetry">
  Telemetry object with position data only
</ResponseField>

***

### get\_weather\_data()

Return weather data for each lap.

<ResponseField name="return" type="pd.DataFrame">
  DataFrame with weather data for each lap
</ResponseField>

***

## Other Methods

### split\_qualifying\_sessions()

Split laps into Q1, Q2, and Q3 sessions.

<ResponseField name="return" type="list[Optional[Laps]]">
  List containing three Laps objects for Q1, Q2, and Q3. Returns None for cancelled sessions.
</ResponseField>

**Example:**

```python theme={null}
quali = session.laps
q1, q2, q3 = quali.split_qualifying_sessions()

if q3 is not None:
    print(f"Q3 fastest: {q3.pick_fastest()['LapTime']}")
```

***

### iterlaps()

Iterator for iterating over all laps.

<ParamField path="require" type="Iterable | None" default="None">
  List of required column names. Only yields laps where all required values are non-null.
</ParamField>

**Example:**

```python theme={null}
for index, lap in laps.iterlaps(require=['LapTime', 'Sector1Time']):
    print(f"Lap {lap['LapNumber']}: {lap['LapTime']}")
```

***

## Lap

Single lap object (returned when slicing Laps to a single row).

**Properties:**

All columns from Laps are accessible as properties on a Lap object.

**Methods:**

### get\_telemetry()

Get telemetry data for this lap.

<ParamField path="frequency" type="int | Literal['original'] | None" default="None">
  Optional frequency override
</ParamField>

<ResponseField name="return" type="Telemetry">
  Telemetry object for this lap
</ResponseField>

***

### get\_car\_data()

Get car data for this lap.

<ResponseField name="return" type="Telemetry">
  Telemetry object with car data
</ResponseField>

***

### get\_pos\_data()

Get position data for this lap.

<ResponseField name="return" type="Telemetry">
  Telemetry object with position data
</ResponseField>

***

### get\_weather\_data()

Get weather data for this lap.

<ResponseField name="return" type="pd.Series">
  Weather data for this lap
</ResponseField>

***

## Complete Usage Example

```python theme={null}
import fastf1
import matplotlib.pyplot as plt

# Load session
session = fastf1.get_session(2023, 'Monaco', 'Race')
session.load()

# Get all laps
laps = session.laps

# Filter laps
ver_laps = laps.pick_drivers('VER').pick_quicklaps()
print(f"Verstappen quick laps: {len(ver_laps)}")

# Get fastest lap
fastest = ver_laps.pick_fastest()
print(f"Fastest lap: {fastest['LapTime']}")
print(f"Compound: {fastest['Compound']}")
print(f"Tyre life: {fastest['TyreLife']} laps")

# Get telemetry for fastest lap
tel = fastest.get_telemetry()

# Plot speed trace
fig, ax = plt.subplots()
ax.plot(tel['Distance'], tel['Speed'])
ax.set_xlabel('Distance (m)')
ax.set_ylabel('Speed (km/h)')
ax.set_title('VER Fastest Lap - Speed Trace')
plt.show()

# Compare two drivers
ver_fastest = laps.pick_drivers('VER').pick_fastest()
ham_fastest = laps.pick_drivers('HAM').pick_fastest()

ver_tel = ver_fastest.get_telemetry()
ham_tel = ham_fastest.get_telemetry()

fig, ax = plt.subplots()
ax.plot(ver_tel['Distance'], ver_tel['Speed'], label='VER')
ax.plot(ham_tel['Distance'], ham_tel['Speed'], label='HAM')
ax.set_xlabel('Distance (m)')
ax.set_ylabel('Speed (km/h)')
ax.legend()
plt.show()
```
