web-dev-qa-db-ja.com

Python-pandasフォーマットエラーの時系列の分析-statsmodels

星のデータを分析しようとしています。星の軽い時系列があり、それらが(4つの異なるタイプの中で)どのクラスに属するかを予測したいと思います。私はそれらの星の軽い時系列を持っているので、季節外れ化、周波数分析、その他の関連する可能性のある研究を行って、それらの時系列を分析したいと考えています。

オブジェクトtime_seriesは、10列を含むパンダDataFrameです:time_points_b、light_points_b(bは青を表します)など...

最初にブルーライト時系列を研究したいと思います。

import statsmodels.api as sm;
import pandas as pd
import matplotlib.pyplot as plt
pd.options.display.mpl_style = 'default'
%matplotlib inline

def star_key(slab_id, star_id_b):
    return str(slab_id) + '_' + str(star_id_b)

raw_time_series = pd.read_csv("data/public/train_varlength_features.csv.gz", index_col=0, compression='gzip')
time_series = raw_time_series.applymap(csv_array_to_float)


time_points = np.array(time_series.loc[star_key(patch_id, star_id_b)]['time_points_b'])
light_points = np.array(time_series.loc[star_key(patch_id, star_id_b)]['light_points_b'])
error_points = np.array(time_series.loc[star_key(patch_id, star_id_b)]['error_points_b'])

light_data = pd.DataFrame({'time':time_points[:], 'light':light_points[:]})
residuals = sm.tsa.seasonal_decompose(light_data);

light_plt = residuals.plot()
light_plt.set_size_inches(10, 5)
light_plt.tight_layout()

このコードでは、seasonal_decomposeメソッドを適用すると属性エラーが発生します。AttributeError: 'Int64Index' object has no attribute 'inferred_freq'

17
Robin

seasonal_decompose()は、DataFrameにDateTimeIndexが必要です。次に例を示します。

enter image description here

23
Randy