forked from open-ct/openda2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
时间统计
36 lines (34 loc) · 1004 Bytes
/
时间统计
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import numpy as np
import pandas as pd
from datetime import datetime
from pandas.core.frame import DataFrame
import matplotlib.pyplot as plt
import time
import ast
import json
df = pd.read_excel('data.xlsx')
total_sec = []
total = []
total = pd.DataFrame(total)
num = 0
for index in range(0, 2707):
row_data = df.loc[index, :]
dt = "2055-01-01 01:01:01"
dlt = datetime.strptime(dt, "%Y-%m-%d %H:%M:%S")
start_time = row_data['start_time']
if str(start_time)!='nan':
start_time = datetime.strptime(start_time, "%Y-%m-%dT%H:%M:%S+08:00")
else:
start_time = dlt
stop_time = row_data['stop_time']
if str(stop_time)!='nan':
stop_time = datetime.strptime(stop_time, "%Y-%m-%dT%H:%M:%S+08:00")
else:
stop_time = dlt
if stop_time==dlt or start_time==dlt:
total_sec.append(0)
else:
tot = (stop_time - start_time).seconds
total_sec.append(tot)
total['作答时间'] = total_sec
total.to_excel('data_test.xlsx')