I have a Age.xlsx where I am calculating the age of incidents in no of Days(Granular level I have to found Age in Hours) I am stuck with a situation, I have to calculate no of days with below two conditions.
- If the completion date is given then No of days= Completed date-submit date
- If the Completed date is NaT(Or blank)(If incident still open then No of days=L1+L2
Additionally, How can I convert days to hours eg. "2 days 08:00:00" to "56 hours"?
Sample data:
Incident Status Priority Team Submit Date Completed Date L1 L2 No_of_days Age_in_Hours
INC0011 Pending Medium L2 2020-06-04 00:00:00 1 1
INC0012 completed High L2 2020-06-04 00:00:00 2020-06-08 02:00:00 2 2
INC0013 In progress Low L1 2020-06-05 00:00:00 1 2
INC0014 Assigned Medium L1 2020-06-05 00:00:00 1 3
INC0015 completed High L2 2020-06-05 00:00:00 2020-06-05 01:00:00 0 1
Sampel code:
data = pd.read_excel('C:\Age.xlsx')
x=(data['Completed Date']- data['Submit Date'])