Issue Description
I'm using models from statsmodels.tsa to do time series analysis and I ran into issue of : ValueError: Buffer dtype mismatch, expected 'double' but got 'long'.
Environment:
MacOS 10.14.5
Anaconda
Syper 3.3.5
Python 3.7.2
statsmodels 0.10.0
Code:
import pandas as pd
import numpy as np
from sklearn.metrics import mean_squared_error
from math import sqrt
from statsmodels.tsa.api import ExponentialSmoothing, SimpleExpSmoothing, Holt
import matplotlib.pylab as plt
import matplotlib.dates as mdates
df = pd.read_csv('data.csv')
dateparse = lambda dates: pd.datetime.strptime(dates, '%Y-%m-%d')
df = pd.read_csv('data.csv',
parse_dates=['Month'],
index_col='Month',
date_parser=dateparse)
df = df.sort_index(axis = 0, ascending=True)
train_rev = df['Revenue'].values[:33]
train_index = pd.date_range('2016-07-01', periods = 33, freq = 'MS')
train = pd.Series(train_rev, train_index)
test_rev = df['Revenue'].values[33:]
test_index = pd.date_range('2019-04-01', periods = 3, freq = 'MS')
test = pd.Series(test_rev, test_index)
ses = SimpleExpSmoothing(train)
ses = ses.fit()
Its giving me this ValueError every time I run the code. To test, I have copied codes from time series analysis tutorials of statsmodels (link: https://www.statsmodels.org/dev/examples/notebooks/generated/exponential_smoothing.html). I can successfully get the final result without any errors. But when I run my code. Its giving me the error.
Would love to know how to fix the issue?
Thanks for your time and help.
You should explicitly cast your data to double, as in train = train.astype('double)`
Thanks for your reply. This solved the issue!
Thanks for reporting, fixed in master.
Most helpful comment
You should explicitly cast your data to
double, as intrain = train.astype('double)`