diff --git a/fastf1/core.py b/fastf1/core.py index 4d3590747..a0d2b46b5 100644 --- a/fastf1/core.py +++ b/fastf1/core.py @@ -1421,6 +1421,11 @@ def _load_laps_data(self, livedata=None): mask = pd.isna(result['LapStartTime']) & (~pd.isna(result['PitOutTime'])) result.loc[mask, 'LapStartTime'] = result.loc[mask, 'PitOutTime'] + # remove first lap pitout time if it is before session_start_time + mask = (result["PitOutTime"] < self.session_start_time) & \ + (result["NumberOfLaps"] == 1) + result.loc[mask, 'PitOutTime'] = pd.NaT + # create total laps counter for each tyre used for npit in result['Stint'].unique(): sel = result['Stint'] == npit diff --git a/fastf1/tests/test_core.py b/fastf1/tests/test_core.py index 561e23c12..5294577ad 100644 --- a/fastf1/tests/test_core.py +++ b/fastf1/tests/test_core.py @@ -39,6 +39,23 @@ def test_lap_data_loading_position_calculation(): assert (delta == 0).all() # assert that the delta is zero for all laps +@pytest.mark.f1telapi +def test_first_lap_pitout_times(): + sprint_session = fastf1.get_session(2023, 4, "Sprint") + sprint_session.load(telemetry=False, weather=False, messages=False) + sprint_laps = sprint_session.laps + sprint_mask = (sprint_laps["LapNumber"] == 1) & \ + (~sprint_laps["PitOutTime"].isna()) + assert sprint_laps[sprint_mask]["Driver"].tolist() == ["OCO"] + + race_session = fastf1.get_session(2023, 5, "R") + race_session.load(telemetry=False, weather=False, messages=False) + race_laps = race_session.laps + race_mask = (race_laps["LapNumber"] == 1) & \ + (~race_laps["PitOutTime"].isna()) + assert race_laps[race_mask]["Driver"].tolist() == [] + + def test_laps_constructor_metadata_propagation(reference_laps_data): session, laps = reference_laps_data