Pandas 对流';%H:%M:%S.%f';在熊猫中度过时光

Pandas 对流';%H:%M:%S.%f';在熊猫中度过时光,pandas,Pandas,我有一个数据帧,其列名为time,字符串值的格式为“%H:%M:%S.%f”。 值的示例: 0 00:00:01.233480 1 00:00:03.212245 2 00:00:05.172649 3 00:00:07.109743 4 00:00:08.934098 我已使用此代码将其转换为时间:df1.time=pd.to_timedelta(df1.time,unit='s') 但是当我运行df1.info()时 <class 'pandas.cor

我有一个数据帧,其列名为time,字符串值的格式为“%H:%M:%S.%f”。
值的示例:

0   00:00:01.233480 
1   00:00:03.212245 
2   00:00:05.172649 
3   00:00:07.109743 
4   00:00:08.934098 
我已使用此代码将其转换为时间:
df1.time=pd.to_timedelta(df1.time,unit='s')

但是当我运行
df1.info()

<class 'pandas.core.frame.DataFrame'>
RangeIndex: 59918 entries, 0 to 59917
Data columns (total 1 columns):
time          59918 non-null datetime64[ns]
dtypes: datetime64[ns](1)

范围索引:59918个条目,0到59917
数据列(共1列):
时间59918非空datetime64[ns]
数据类型:datetime64[ns](1)
我很困惑,因为时间的单位是datetime64[ns],纳秒,但它应该是秒


这对我来说很重要,因为我稍后会尝试绘制它,而这会使绘图变得混乱。

如果你想舍入到秒,可能会有帮助如果你想舍入到秒,可能会有帮助