Reputation: 508
I know there are similar questions posted, but not exactly lining up to my use case.
I have a pandas column of timedelta values :
0 days 10:46:22.000000000
That I would like to look like an integer:
10.46
Is there a simple way to do so by extracting hours and minutes?
Upvotes: 0
Views: 908
Reputation: 142226
Convert your Timedelta
s to seconds and divide by 3600:
s = pd.Series([pd.Timedelta('0 days 10:46:22.000000000'), pd.Timedelta('5 days 100:31:22.000000000')])
float_hours = s.dt.total_seconds() / 3600
Gives:
0 10.772778
1 220.522778
dtype: float64
Upvotes: 2