Time:11-01
CodePudding user response:
time format is???????
Quote: refer to 1st floor JMZL response: time format is??????? time format for the date when the minutes, the standard format of time
Quote: refer to the second floor weixin_45609906 response: Quote: refer to 1st floor JMZL response: time format is??????? time format for the date when the minutes, the standard format of time Put into seconds do subtraction operation time, and take the absolute value is seconds to hours interval the number of hours
is not clock time, with the calculated time difference with small of the time is the number of hours in addition to take more than 24 hours of the morning time
have a 10 rows of data and hi test ah, Should be 2, 3 line also put
Def test_time () : The import pandas as pd The import time Def get_hour (x) : Return the x [13] Def check_time (x1, x2) : T1=int (time. Mktime (time. Strptime (x2, '% % Y - m - H: % d % % m: % S. 0'))) - int (time. Mktime (time. Strptime (x1, '% % Y - m - H: % d % % m: % S. 0'))) Return the t1/3600 Df1=pd. Read_excel (' test1. XLSX, 0) Print (df1) Df1 [' time3]=df1. Apply (lambda x: check_time (x.t ime1, x.t ime2), axis=1) Df1 [' time1_h]=df1. Apply (lambda x: get_hour (x.t ime1), axis=1) Print (df1) Print (df1 [df1 [' time1_h] & gt; '05']) Test_time ()
3 2019-10-05 23:44:00. 0 2019-10-07 05:02:57. 0 4 the 2019-10-05 23:48:53. 0 2019-10-07 05:02:57. 0 The calculation process of the two description,
Quote: old coconut reference 15 floor response: 3 2019-10-05 23:44:00. 0 2019-10-07 05:02:57. 0 4 the 2019-10-05 23:48:53. 0 2019-10-07 05:02:57. 0 The calculation process of the two description, time at 1 PM to 5 am every day length is not included in the calculation time effectively,
this judgment is more complicated, Feel to convert/hour, the number of seconds to traverse the list to solve it,
Page link:https//www.codepudding.com/other/75400.html