Skip to content

Is there a way to acquire driver gaps at the end of each lap? #503

Answered by theOehrly
laurence9899 asked this question in Q&A
Discussion options

You must be logged in to vote

One of those samples is always taken at the finish line. They timestamps line up reasonably well with the timing data. Therefore you can use the sample with the smallest absolute difference between its timestamp and the time at which the lap was set.

I'm using the following code internally for the same problem:

def _get_gap_str_for_drv(drv, idx, laps_data, stream_data):
    first_time = laps_data[laps_data['Driver'] == drv].iloc[idx]['Time']
    ref_idx = (stream_data[stream_data['Driver'] == drv]['Time']
               - first_time).abs().idxmin()
    gap_str = stream_data.loc[ref_idx]['GapToLeader']
    return gap_str

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@laurence9899
Comment options

Answer selected by laurence9899
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants