Convert series datetime data into total hours

I've a dataframe named mainData_Frame with column 'Clearance Time' in the following format.

Clearance Time 2 days 22:43:00 1 days 12:32:23 5 days 23:44:13 . . . .

I need to convert all timedelta series at 'Clearance Time' column into numeric hours. What I applied is the following codes:

import pandas as pd
import datetime

def convert_to_hours(time_string):
    time = datetime.datetime.strptime(time_string, '%d days %H:%M:%S')
    delta = datetime.timedelta(days=time.day, hours=time.hour, minutes=time.minute, seconds=time.second)
    return delta.total_seconds()/3600

timeData = pd.Series(mainData_Frame['Clearance Time'])
num_Hours = timeData.apply(convert_to_hours)

print(num_Hours)

But got the following errors:

TypeError: strptime() argument 1 must be str, not Timedelta

I'm the beginner in python and having some project regarding this, please help to sort out.

No need for a function here, use built-ins :

ser = pd.to_timedelta(mainData_Frame["Clearance Time"])
​
timeData = ser.dt.total_seconds().div(3600)
​

Output :

print(timeData)

0     70.716667
1     36.539722
2    143.736944
Name: Clearance Time, dtype: float64
Back to Top