Reputation: 25
I have tried the following without luck:
df['TimedSpentInZone'] = df.TimedSpentInZone.astype(int)
df['TimedSpentInZone'] = df['TimedSpentInZone'].dt.total_seconds()
df['TimedSpentInZone'] = df['TimedSpentInZone'].dt.hours
(And also divided by 60 etc to get minutes. none of the above works.
Upvotes: 2
Views: 5365
Reputation: 2022
Its been a long time, but for future readers, this is what I did;
From the looks of it this column in the question is already a Timedelta type. If thats your case, you don't need to convert it.
Just get
df['TimeSpentInZone'].dt.seconds / 60
to get the minutes.
Upvotes: 2
Reputation: 150815
You can, and should convert to Timedelta
type:
pd.to_timedelta(df['TimedSpentInZone'])/pd.Timedelta('60s')
Upvotes: 5