3
私はここにいる。私は、とこのTIME SERIE DECOMPOSITION EXAMPLEに続いて、タイムセリエを分解しようとしています。Pythonで季節的なARIMA、Hが分からない?
私の問題はstatsmodels.tsa.seasonalから輸入season_decompose機能です。 私はデータを成功させることなくそれをどのようにデータに適用するかを考えています。 これは私のコードです:
import os
import csv
import time
import datetime
import pandas as pd
import numpy as np
import statsmodels.api as sm
from datetime import datetime
from datetime import timedelta, date
from dateutil.relativedelta import relativedelta
from statsmodels.tsa.seasonal import seasonal_decompose
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
from itertools import product
df = pd.read_csv('table.csv', index_col=0)
df.index.name=None
df.reset_index(inplace=True)
start = datetime.strptime("2015-10-10", "%Y-%m-%d")
date_list = [start + relativedelta(days =x , hour=y) for x,y in product(range(0,93), range(0,24))]
df['index'] =date_list
df.set_index(['index'], inplace=True)
df.index.name=None
df.columns= ['Close']
df['Close'] = df.Close.apply(lambda x: int(x))
df.Close.plot(figsize=(12,8), title= 'Monthly Closehip', fontsize=14)
decomposition = seasonal_decompose(df.Close, freq=93)
fig = decomposition.plot()
fig.set_size_inches(15, 8)
plt.show()
は、私は次のエラーを得た:
https://docs.google.com/a/esi.dz/spreadsheets/d/1s2Ak6Rqgm43FV4G_J_giWeHyi38xdZCBCz2v34k7iuA/edit?usp=sharing
がしようとすると、私を助けてください:
Traceback (most recent call last):
File "test.py", line 59, in <module>
decomposition = seasonal_decompose(df.Close, freq=93)
File "/usr/local/lib/python2.7/dist-packages/statsmodels/tsa/seasonal.py", line 70, in seasonal_decompose
pfreq = freq_to_period(pfreq)
File "/usr/local/lib/python2.7/dist-packages/statsmodels/tsa/tsatools.py", line 657, in freq_to_period
"think this in error.".format(freq))
ValueError: freq H not understood. Please report if you think this in error.
データはcsvファイルです。
はい、それは現在必要なのです。これはすぐに変更されるので、明示的に指定された 'freq'がその場合のpandasシリーズの時間インデックスから取得する代わりに使用されます。 – user333700