I am a newbie in learning Machine Learning, so following a great tutorial in YouTube. But the following code is giving me an error. I read a similar question in here, but timetuple()
does not solve my case, nor any solutions from the video.
Here is my code :
import pandas as pd import quandl, math from datetime import datetime, date, time, timedelta import time import numpy as np from sklearn import preprocessing, cross_validation, svm from sklearn.linear_model import LinearRegression import matplotlib.pyplot as plt #plot stuff, how to plot in graph from matplotlib import style #nice looking thing style.use('ggplot') #which nice-looking-thing i wanna use quandl.ApiConfig.api_key = '...' #erased my key for secrecy df = quandl.get_table('WIKI/PRICES') ## ... ##other irrelevant code snippets forecast_out = int(math.ceil(0.01*len(df))) df['label'] = df[forecast_col].shift(-forecast_out) X = np.array(df.drop(['label'],1)) X = preprocessing.scale(X) X_lately = X[-forecast_out:] X = X[:-forecast_out] df.dropna(inplace=True) y = np.array(df['label']) y = np.array(df['label']) # ... #other irrelevant code snippets forecast_set = clf.predict(X_lately) df['Forecast'] = np.nan last_date = df.iloc[-1].name last_unix = last_date.timestamp() ###MAIN attribute error found here one_day = 86400 next_unix = last_unix + one_day
For this above code, I got this following error :
AttributeError Traceback (most recent call last) <ipython-input-8-4a1a193ea81d> in <module>() 1 last_date = df.iloc[-1].name ----> 2 last_unix = last_date.timestamp() 3 one_day = 86400 4 next_unix = last_unix + one_day AttributeError: 'numpy.int64' object has no attribute 'timestamp'
I couldn't figure out the solution though there are many solutions in the internet but nothing worked for me. I am using Python 3.5 in anaconda. timetuple()
doesn't work for me and same attribute error occurs.