Created
October 23, 2022 18:40
-
-
Save natyrix/82f22e951fa53819781f47e8960e232e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def calculate_speeds(self, starting_time_list, ending_time_list, distance_list): | |
speed_list = [] | |
for i in range(len(starting_time_list)): | |
try: | |
start_datetime_object = datetime.strptime(starting_time_list[i], '%Y-%m-%d %H:%M:%S') | |
end_datetime_object = datetime.strptime(ending_time_list[i], '%Y-%m-%d %H:%M:%S') | |
time_taken = end_datetime_object-start_datetime_object | |
hrs = time_taken.total_seconds()/3600 | |
speed_list.append(distance_list[i]/hrs) | |
except Exception as e: | |
speed_list.append(0.0) | |
return speed_list |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment