我正在嘗試將嗅探時間轉換為秒數。我已經在Python Pandas DataFrame中查看了將timedelta64[ns]列轉換為秒,但是該解決方案不起作用。我想也許熊貓線可能有錯。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())
1 回答

繁星淼淼
TA貢獻1775條經驗 獲得超11個贊
您可以將 numpy 標量轉換為 Timedelta
,因此可以使用Timedelta.total_seconds
:
df['PerSec']=df['PerSec'].div(pd.Timedelta(sniffTime).total_seconds())
添加回答
舉報
0/150
提交
取消