gpt4 book ai didi

python - 属性错误 : 'Timestamp' object has no attribute 'timestamp'

转载 作者:太空狗 更新时间:2023-10-30 00:59:33 28 4
gpt4 key购买 nike

我正在努力让我的代码运行。时间戳似乎有问题。您对我如何更改代码有什么建议吗?我看到之前有人问过这个问题,但没能成功。

这是我在运行代码时遇到的错误:'Timestamp' object has no attribute 'timestamp'

我的代码:

import quandl, math, datetime

last_date = df.iloc[-1].name
last_unix = last_date.timestamp()
one_day = 86400 #Seconds in a day
next_unix = last_unix + one_day


for i in forecast_set:
next_date = datetime.datetime.fromtimestamp(next_unix)
next_unix += one_day
df.loc[next_date]=[np.nan for _ in range(len(df.columns)-1)]+[i]
#Loop to replace all numbers on x axis with dates

最佳答案

你可以试试这个:

import time
.....
last_unix = time.mktime(last_date.timetuple())

这对我有用!

关于python - 属性错误 : 'Timestamp' object has no attribute 'timestamp' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40473442/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com