将对象转换为日期时间。时间格式大于24小时
convert object to datetime . time format more than 24 hours
我得到的数据是时间格式包含一些时间超过 24 小时的行。
数据还包括日期参数
时间 26:00 表示后一天 2:00
最大时间是 28:00
我想创建日期时间参数
但是因为时间参数是一个对象,所以它不允许我这样做。
当我尝试转换时,它说“小时必须在 0..23 中:24:00:02”
有什么建议吗?
编辑:
我需要日期时间
您可以使用 pandas 中的 to_timedelta 和 to_datetime。
df['date time'] = pd.to_datetime(df['date'], format='%d.%m.%y') + pd.to_timedelta(df['time'])
我得到的数据是时间格式包含一些时间超过 24 小时的行。
数据还包括日期参数
时间 26:00 表示后一天 2:00
最大时间是 28:00
我想创建日期时间参数 但是因为时间参数是一个对象,所以它不允许我这样做。 当我尝试转换时,它说“小时必须在 0..23 中:24:00:02”
有什么建议吗?
编辑: 我需要日期时间
您可以使用 pandas 中的 to_timedelta 和 to_datetime。
df['date time'] = pd.to_datetime(df['date'], format='%d.%m.%y') + pd.to_timedelta(df['time'])