Skip to content

Commit

Permalink
ENH: Add pick_inlaps() and pick_outlaps() functions (#454)
Browse files Browse the repository at this point in the history
  • Loading branch information
pesaventofilippo authored Oct 9, 2023
1 parent ada61fa commit 97c4ec8
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions fastf1/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2921,6 +2921,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

0 comments on commit 97c4ec8

Please sign in to comment.