pandas 在 Python 中分析时间序列 - 熊猫格式错误 - statsmodels
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/34342370/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Analysing Time Series in Python - pandas formatting error - statsmodels
提问by Robin
I am trying to analyse stars' data. I have light time series of the stars and I want to predict to which class (among 4 different types) they belong. I have light time series of those stars, and I want to analyse those time series by doing deseasonalisation, frequencies analysis and other potentially relevant studies.
我正在尝试分析明星的数据。我有星星的光时间序列,我想预测它们属于哪个类(在 4 种不同类型中)。我有这些恒星的光时间序列,我想通过去季节化、频率分析和其他可能相关的研究来分析这些时间序列。
The object time_series is a panda DataFrame, including 10 columns : time_points_b, light_points_b (the b being for blue), etc...
对象 time_series 是一个Pandas数据帧,包括 10 列:time_points_b、light_points_b(b 代表蓝色)等...
I first want to study the blue light time series.
我首先想研究蓝光时间序列。
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()
This code gives me an attribute error when I apply the seasonal_decompose method : AttributeError: 'Int64Index' object has no attribute 'inferred_freq'
当我应用season_decompose 方法时,此代码给了我一个属性错误: AttributeError: 'Int64Index' object has no attribute 'inferred_freq'