rafine
rafine

Reputation: 471

convert object to datetime . time format more than 24 hours

I got data that the time format include some rows that the time is more than 24 hours.

the data also incluse date parameter

time 26:00 mean the day after at 2:00

max time is 28:00

I want to create datetime parameter but because the time parameter is an object it doesn't let me to it. and when I try to convert it says "hour must be in 0..23: 24:00:02"

any suggestion what to do?

edit: i need the date time

enter image description here

Upvotes: -1

Views: 817

Answers (1)

norie
norie

Reputation: 9857

You could use to_timedelta and to_datetime from pandas.

df['date time'] =  pd.to_datetime(df['date'], format='%d.%m.%y') + pd.to_timedelta(df['time'])

Upvotes: 1

Related Questions