Jun-27-2021, 08:08 AM
Hello
I am currently attempting to create a web dashboard for analytics in Formula1 using plotly and flask as per the article
An Interactive Web Dashboard with Plotly and Flask.
I have lap times in string format of MM:SS:sss (where MM is minutes and sss is milliseconds) and I have attempted (python script below) to convert this to quantifiable values using datetime.timedelta so that I am able to graph them and manipulate them (e.g find the average time of a driver over a number of laps). However when I try graphing the timedelta objects in plotly, they are displayed in microseconds.
In seeing the code above, I want the string_con_list() function to return a list of timedelta objects in MM:SS:sss format. Please may someone point me in the right direction. Thank you.
I am currently attempting to create a web dashboard for analytics in Formula1 using plotly and flask as per the article
An Interactive Web Dashboard with Plotly and Flask.
I have lap times in string format of MM:SS:sss (where MM is minutes and sss is milliseconds) and I have attempted (python script below) to convert this to quantifiable values using datetime.timedelta so that I am able to graph them and manipulate them (e.g find the average time of a driver over a number of laps). However when I try graphing the timedelta objects in plotly, they are displayed in microseconds.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
times = [ "1:23.921" , "1:24.690" , "1:24.790" ] # convert to timedelta object def string_con(string_time): new_time = timedelta(minutes = int (string_time.split( ":" )[ 0 ]), seconds = int ((string_time.split( ":" )[ 1 ]).split( "." )[ 0 ]), milliseconds = int ((string_time.split( ":" )[ 1 ]).split( "." )[ 1 ])) return new_time # convert to timedelta object - list def string_con_list(string_times): laps = list ( map (string_con, string_times)) return laps # compute average pace using timedelta objects def average_pace(laps): laps = list ( map (string_con, laps)) return ( sum (laps, timedelta( 0 )) / len (laps)) print (string_con_list(times)) print (average_pace(times)) |