Home > other >  Excel two columns of the time, how to evaluate time lag, excluding 1-5 hours.
Excel two columns of the time, how to evaluate time lag, excluding 1-5 hours.

Time:11-01

How to use processing of pandas, a great god guidance on, please.

CodePudding user response:

What is the time format???

CodePudding user response:

reference 1st floor JMZL response:
time format is???????
time format for the date when the minutes, the standard format of time

CodePudding user response:

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

CodePudding user response:

reference JMZL reply: 3/f
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
mainly eliminate the night time, calculated as hours not achieve them

CodePudding user response:

Clock in time, with the calculated time difference with small of the time the number of hours in addition to take more than 24 is the morning time

CodePudding user response:

The
reference 5 floor JMZL response:
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
can't eliminate

CodePudding user response:

Have a 10 rows of data and hi test ah,

Should be 2 or 3 line statements

CodePudding user response:

Data format below, a great god for guidance on how to implement the length calculation, pandas
The start time to end time correct calculation time
The 2019-10-03 12:28:17. 0 2019-10-03 12:32:01. 0
0.062222222The 2019-10-03 15:04:30. 0 2019-10-03 15:08:44. 0
0.070555555The 2019-10-03 11:59:39. 0 2019-10-03 12:03:21. 0
0.061666667The 2019-10-05 23:44:00. 0 2019-10-07 05:02:57. 0
20.28583333The 2019-10-05 23:48:53. 0 2019-10-07 05:02:57. 0
20.20444444The 2019-10-03 16:59:55. 0 2019-10-03 17:04:03. 0
0.068888889The 2019-10-03 12:07:05. 0 2019-10-03 13:39:55. 0
1.547222222The 2019-10-07 03:29:40. 0 2019-10-07 03:32:39. 0 0
The 2019-10-07 03:36:32. 0 2019-10-07 03:41:32. 0 0
The 2019-10-07 14:46:58. 0 2019-10-07 15:25:56. 0
0.649444444

CodePudding user response:

refer to 7th floor old coconut response:
have a 10 rows of data and hi test ah,

Should be 2, 3 line also put
time format as follows,

CodePudding user response:

 
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 ()


CodePudding user response:

3 the 2019-10-05 23:44:00. 0 2019-10-07 05:02:57. 0, 29.315833 23
4 the 2019-10-05 23:48:53. 0 2019-10-07 05:02:57. 0, 29.234444 23
Across the day did not eliminate the night time, correct calculation of 20.28583333, 20.20444444 hours,

CodePudding user response:


Calculation results of the above is correct

CodePudding user response:

Add is adjusted from 1 to 5 o 'clock at night long calculation results correctly,

CodePudding user response:

> 29.315833 20.28583333
9.029999670000002

Excluding 1-5 hours mean?

CodePudding user response:

3 the 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,

CodePudding user response:

reference 15 floor old coconut 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,

CodePudding user response:

reference 16 floor weixin_45609906 response:
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,
correct once, 1 a.m. and the length of the six o 'clock every day not plan

CodePudding user response:

This judgment is more complicated,
Feel to convert/hour, the number of seconds to traverse the list to solve it,

CodePudding user response:

refer to the 18th floor old coconut response:
this judgment is more complicated,
Feel to convert/hour, the number of seconds to traverse the list to solve it,
is to estimate the for loop + if judgment, tried a few times can't write it out
  • Related