Hi,
I'm trying this time to use a simple linear regression on my time series dataset to linearly predict data. But I got this error and I don't know how to handle it. Any ideas?
I'm trying this time to use a simple linear regression on my time series dataset to linearly predict data. But I got this error and I don't know how to handle it. Any ideas?
# print df.head() eie Date_Time 2017-11-10 4470.76 2017-11-11 5465.72 2017-11-12 15465.72 2017-11-13 25465.72 2017-11-14 21480.59 y = np.array(df.values, dtype=float) x = np.array(pd.to_datetime(df['eie']).index.values, dtype=float) slope, intercept, r_value, p_value, std_err =sp.linregress(x,y) xf = np.linspace(min(x),max(x),100) xf1 = xf.copy() xf1 = pd.to_datetime(xf1) yf = (slope*xf)+intercept print('r = ', r_value, '\n', 'p = ', p_value, '\n', 's = ', std_err)# Error
Error:ValueError Traceback (most recent call last)
<ipython-input-13-5d30a02ce6af> in <module>
1 y = np.array(df.values, dtype=float)
----> 2 x = np.array(pd.to_datetime(df['eie']).index.values, dtype=float)
3
4 slope, intercept, r_value, p_value, std_err =sp.linregress(x,y)
5
ValueError: could not convert string to float: '2017-11-10'