Pandas 将整数转换为时间

Pandas 将整数转换为时间,pandas,time,Pandas,Time,我有这样的时间列,以秒为单位 100 100000 235900 我想转换成时间格式,即 00:01 01:00 23:59 我试过了 time = pd.to_datetime(temp['time'], format='%H%M%S').dt.time 但是它扔 ValueError: time data '0' does not match format '%H%M%S' (match) 用于将整数转换为字符串: time = pd.to_datetime(temp['time']

我有这样的时间列,以秒为单位

100
100000
235900
我想转换成时间格式,即

00:01
01:00
23:59
我试过了

time = pd.to_datetime(temp['time'], format='%H%M%S').dt.time
但是它扔

ValueError: time data '0' does not match format '%H%M%S' (match)
用于将整数转换为字符串:

time = pd.to_datetime(temp['time'].astype(str).str.zfill(6), format='%H%M%S').dt.time
print (time)
0    00:01:00
1    10:00:00
2    23:59:00
Name: time, dtype: object
如果需要时间增量:

s = temp['time'].astype(str).str.zfill(6)

td = pd.to_timedelta(s.str[:2] + ':' + s.str[2:4] + ':' + s.str[4:])
print (td)
0   00:01:00
1   10:00:00
2   23:59:00
Name: time, dtype: timedelta64[ns]
或:

td= pd.to_timedelta(time.astype(str))
print (td)
0   00:01:00
1   10:00:00
2   23:59:00
Name: time, dtype: timedelta64[ns]