我正在尝试将sniffTime转换为几秒钟。我已经看过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())发布于 2020-03-02 11:09:10
您可以将numpy标量转换为Timedelta,因此可以使用Timedelta.total_seconds。
df['PerSec']=df['PerSec'].div(pd.Timedelta(sniffTime).total_seconds())https://stackoverflow.com/questions/60487583
复制相似问题