質問するログイン新規登録

質問編集履歴

1

追記

2020/02/20 08:12

投稿

Pablito
Pablito

スコア71

title CHANGED
File without changes
body CHANGED
@@ -107,9 +107,56 @@
107
107
  ### 試したこと
108
108
 
109
109
  元データの’を消してみたり、したのですが効果はなし。
110
- dateがdatetime型なのですが
110
+ dateがdatetime型なので、
111
- これをint型に変える必要があるのでか?
111
+ 以下のコードでint型にしたところ、違エラーが返ってきました。
112
+ ```
113
+ def to_integer(dt_time):
114
+ return 10000*dt_time.year + 100*dt_time.month + dt_time.day
112
115
 
116
+ guests['date'] = guests['date'].apply(to_integer)
117
+ ```
118
+
119
+ ```
120
+ ---------------------------------------------------------------------------
121
+ ValueError Traceback (most recent call last)
122
+ <ipython-input-12-d64133e2c242> in <module>
123
+ 3
124
+ 4 #最尤法によるパラメーターの推定
125
+ ----> 5 res_local_level = mod_local_level.fit()
126
+ 6
127
+ 7 #推定されたパラメーター一覧
128
+
129
+ c:\users\lib\site-packages\statsmodels\tsa\statespace\mlemodel.py in fit(self, start_params, transformed, includes_fixed, cov_type, cov_kwds, method, maxiter, full_output, disp, callback, return_params, optim_score, optim_complex_step, optim_hessian, flags, low_memory, **kwargs)
130
+ 605 """
131
+ 606 if start_params is None:
132
+ --> 607 start_params = self.start_params
133
+ 608 transformed = True
134
+ 609 includes_fixed = True
135
+
136
+ c:\users\lib\site-packages\statsmodels\tsa\statespace\structural.py in start_params(self)
137
+ 846 _start_params = {}
138
+ 847 if self.level:
139
+ --> 848 resid, trend1 = hpfilter(endog)
140
+ 849
141
+ 850 if self.stochastic_trend:
142
+
143
+ c:\users\lib\site-packages\statsmodels\tsa\filters\hp_filter.py in hpfilter(x, lamb)
144
+ 88 """
145
+ 89 pw = PandasWrapper(x)
146
+ ---> 90 x = array_like(x, 'x', ndim=1)
147
+ 91 nobs = len(x)
148
+ 92 I = sparse.eye(nobs, nobs) # noqa:E741
149
+
150
+ c:\users\lib\site-packages\statsmodels\tools\validation\validation.py in array_like(obj, name, dtype, ndim, maxdim, shape, order, contiguous, optional)
151
+ 134 if arr.ndim != ndim:
152
+ 135 msg = '{0} is required to have ndim {1} but has ndim {2}'
153
+ --> 136 raise ValueError(msg.format(name, ndim, arr.ndim))
154
+ 137 if shape is not None:
155
+ 138 for actual, req in zip(arr.shape, shape):
156
+
157
+ ValueError: x is required to have ndim 1 but has ndim 2
158
+ ```
159
+
113
160
  ###環境
114
161
  pandas 1.0.0
115
162
  numpy 1.18.1