AttributeError:'Timestamp'对象没有属性'timestamp'

Jør*_*sen 5 python timestamp python-2.7

我正在努力让我的代码运行.时间戳似乎有问题.您对我如何更改代码有什么建议吗?我之前看到过这个问题,但是没有设法让它发挥作用.

这是运行代码时出现的错误: '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
Run Code Online (Sandbox Code Playgroud)

Mik*_*son 5

你可以试试这个:

import time
.....
last_unix = time.mktime(last_date.timetuple())
Run Code Online (Sandbox Code Playgroud)

这对我有用!