f1dataR
f1dataR copied to clipboard
Allow more than one driver to be selected in session
As we move towards more functionality for users we can also allow more than one driver using .pick_drivers() instead of .pick_driver() (https://docs.fastf1.dev/core.html#fastf1.core.Laps.pick_drivers).
I'm still trying to figure out .pick_lap() to see if it's possible to use that for lap selection instead of the proposed .slice_by_lap()
Looks like telemtry.slice_by_lap() actually requires a lap object to be supplied as a parameter, not just an integer value as I had assumed. Since laps.pick_lap() takes only a length one integer value (i.e. can't pick a range of laps, according to the docs), it might be best to offer:
- fastest
- Lap (integer, length = 1)
- all as the options for which laps to pick.
As for drivers, that should be fine, as long as we can differentiate the drivers in the resulting data.frame. Might need to create a wrapping function that just calls load_telemetry() multiple times, with each unique driver_code as the supplied arguement, finishing by just row binding the results together.
So, I looked at this and drafted up the code - but (critically) the fastf1 return doesn't include the driver_id. If we use .pick_drivers() we get a data.frame of telemetries (similar to what you'd get from rbinding the individual driver telemetries) but without any driver_id to specify to whom each row belongs.
^ Above commit currently doesn't leave driver_id column in results...
Maybe it's better to update the function to allow for lap selection, but keep it limited to single driver returns? One could always manually rbind their drivers' telemetry data.frames outside of the package, but limiting the function to just fastest or all makes extracting the nth lap difficult.
This is now part of FastF1 (python) and we'll have to adapt our code to match: https://docs.fastf1.dev/changelog/index.html#what-s-new-in-v3-1-0
Fantastic