嗨,我对从时间列表到每次测试的平均时间有疑问。
输出:
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']
预期结果:
test_name =平均时间 例如:
test2 = 0:23:15:442000
我试图将str转换为时间:
time == dt.strptime(str(time), '%H:%M:%S.%f')
但是我不能一直求和,然后除以列表的长度。
您能帮我解决这个问题吗?
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])
答案 0 :(得分:0)
已解决。
@productlog =
EXTRACT Product_ID string,
Prduct_Name string
FROM "/Staging/Products.csv"
USING Extractors.Csv();
@output = Select Product_ID, Product_Name.trim() from @productlog;
OUTPUT @output
TO "/Output/Products.csv"
USING Outputters.Csv();