1 回答
TA贡献1796条经验 获得超10个赞
对于Req_time_taken1, 使用pandas.Series.str.split:
df['Req_time_taken1'] = df['Req_time_taken'].astype(str).str.rsplit(':', 1).str[0]
对于Req_time_taken2, 使用pandas.Series.dt.total_seconds:
df['Req_time_taken2'] = df['Req_time_taken'].dt.total_seconds().apply(lambda x: '%s hours %s minutes' % (x//3600, x%3600/60))
print(df)
输出:
request Req_Created Req_Closed Req_time_taken \
0 REQ0079455 15/05/2019 16:51 23/05/2019 20:53 8 days 04:02:00
1 REQ0079455 15/05/2019 16:51 23/05/2019 20:53 8 days 04:02:00
Req_time_taken1 Req_time_taken2
0 8 days 04:02 196.0 hours 2.0 minutes
1 8 days 04:02 196.0 hours 2.0 minutes
添加回答
举报