python实现-时间序列分析
python实现-时间序列分析 import numpy as np import pandas as pd import datetime import matplotlib.pyplot as plt import statsmodels.api as sm from dateutil.relativedelta import relativedelta from statsmodels.tsa.seasonal import seasonal_decompose #首先处理下数据 data=pd.read_excel("/Users/huangqiankun/Downloads/时时序数据.xlsx",index_col=0) print(data.head(10)) data.index.name = None # 将index的name取消 data.reset_index(inplace=True) data.drop(data.index[64], inplace=True) start = datetime.datetime.strptime("2003-01", "%Y-%m") # 把一个时间字符串解析为时间元组 date_list = [start + relativedelta(months=x*3) for x in range(0, 64)] #