Hi I have a problem with average time from list of times to each test.
output:
test1 ['0:02:30.000000', '0:02:28.000000', '0:02:31.000000', '0:02:33.000000', '0:02:34.000000', '0:02:37.000000', '0:02:30.000000', '0:02:30.000000']
test2 ['0:23:25.789000', '0:23:04.653000']
test3 ['0:32:21.873000', '0:32:33.752000', '0:33:30.383000', '0:32:29.835000']
expected result:
test_name = average time on example:
test2 = 0:23:15:442000
I tried to convert str to time:
time == dt.strptime(str(time), '%H:%M:%S.%f')
but then i cannot sum all times and then divide to length of list.
Could you please help me with this issue?
def average_time(file_path):
df = pd.DataFrame(pd.read_excel(file_path))
test_names_list = collections.Counter(df.iloc[:, 0])
times_list = {}
for test_name in test_names_list:
times_list[test_name] = []
for row in range(df.shape[0]):
if str(df.iloc[row, 0]) == test_name:
times_list[test_name].append(str(df.iloc[row, 5]))
print(test_name, times_list[test_name])