I have a dataframe containing timestamps on two of its columns, and I want to substract them such that I get the time difference in hours and minutes.
ColA    Timestamp           Timestamp2            
1   06:40:00              17:40:00     
2   06:29:00              16:29:00          
3   07:05:00              15:29:00  
4   06:43:00              18:55:00   
I tried the following code but it only gives me the number of hours (an integer).
for m in range(4):
    j = df.iloc[m,0]
    d1 = df.iloc[m,2]
    d2 = df.iloc[m,1]
    td = d1-d2
    q = td.total_seconds() / 3600
    print ("Timeinterval %s is %d hours." %(j, q))
I also tried it with the function (it gives me a tuple, or if I ignore the thing after the comma I get the same result as before):
def days_hours_minutes(td):
    return td.seconds//3600, (td.seconds//60)%60
Also,
def datetime_to_float(d):
    return d.timestamp()
throws "'Timedelta' object has no attribute 'timestamp'".
The difference between the two timestamps works, but I want the output to be a float (ex: 8.5 hours).
 
     
    