Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pick_inlaps() and pick_outlaps() functions (from #453) #454

Merged
merged 4 commits into from
Oct 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions fastf1/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2908,6 +2908,34 @@ def pick_wo_box(self) -> "Laps":
"""
return self[pd.isnull(self['PitInTime']) & pd.isnull(self['PitOutTime'])]

def pick_box_laps(self, which: str = 'both') -> "Laps":
"""Return all laps which are either in-laps, out-laps, or both.
Note: a lap could be an in-lap and an out-lap at the same time.
In that case, it will get returned regardless of the 'which'
parameter.

Args:
which (str): one of 'in'/'out'/'both'

- which='in': only laps in which the driver entered
the pit lane are returned
- which='out': only laps in which the driver exited
the pit lane are returned
- which='both': both in-laps and out-laps are returned

Returns:
instance of :class:`Laps`
"""
if which == 'in':
return self[~pd.isnull(self['PitInTime'])]
elif which == 'out':
return self[~pd.isnull(self['PitOutTime'])]
elif which == 'both':
return self[~pd.isnull(self['PitInTime'])
| ~pd.isnull(self['PitOutTime'])]
else:
raise ValueError(f"Invalid value '{which}' for kwarg 'which'")

def pick_not_deleted(self) -> "Laps":
"""Return all laps whose lap times are NOT deleted.

Expand Down