AttributeError:'numpy.timedelta64'对象没有包含参数的属性'total_seconds'

2024-09-24 02:20:27 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图将时间转换为秒数。我已经研究过Convert timedelta64[ns] column to seconds in Python Pandas DataFrame但该解决方案不起作用。我想可能是线路出了问题

print(sniffTime)
print(type(sniffTime))

产出:

821693000 nanoseconds
<class 'numpy.timedelta64'>

错误

AttributeError: 'numpy.timedelta64' object has no attribute 'total_seconds'

在线:

df['PerSec']=df['PerSec'].div(sniffTime.total_seconds())

Tags: toinnumpyconvertdf时间columntotal