I have a ValueError: year is out of range python
for the below code for aiming to plot curve fit on time series.
Can anyone explain to me why I am getting this error?
x_values_formatted=[]
for i in x_values_edited:
x_values_formatted.append(time.mktime(i.timetuple()))
poly = np.polyfit(x_values_formatted, y_values, 3)
polynomial = np.poly1d(poly)
xs = np.linspace(np.min(x_values_formatted), np.max(x_values_formatted), len(x_values_formatted))
y_int = polynomial(xs)
plt.plot(x_values_edited, y_values, '.')
**plt.plot(xs, y_int)**
plt.show()
data sample:
All inputs have a length of 1400
x_values_formatted:
[1420088220.0, 1420088160.0, 1420088100.0, 1420088040.0, 1420087980.0, 1420087920.0, 1420087860.0, 1420087800.0, 1420088340.0, 1420088280.0, 1420130940.0, 1420130880.0, 1420130820.0, 1420130760.0, 1420130700.0..
y_values:
[79.5, 79.5, 80.0, 80.25, 81.5, 81.5, 84.25, 83.0, 79.5, 77.0, 88.5, 89.0, 88.0, 89.5, 88.75, 90.0, 89.0, 89.5, 88.5, 91.0, 85.5, 80.5, 83.75, 80.25, 82.25, 80.0,
xs:
[ 1.42006320e+09 1.42006326e+09 1.42006332e+09 ..., 1.42014942e+09 1.42014948e+09 1.42014954e+09]
y_int:
[ 71.45402408 71.48215866 71.51025748 ..., 74.95840454 74.93510818 74.91177654]
x_values_edited
[datetime.datetime(2015, 1, 1, 6, 57), datetime.datetime(2015, 1, 1, 6, 56), datetime.datetime(2015, 1, 1, 6, 55), datetime.datetime(2015, 1, 1, 6, 54), datetime.datetime(2015, 1, 1, 6, 53), datetime.datetime(2015, 1, 1, 6, 52),