2024-04-29 03:56:39 发布
网友
我希望使用Python季节性地调整月度数据。从这些序列中可以看到:www.emconfidential.com,数据中有很高的季节性成分。我想对此进行调整,以便在系列趋势上升或下降时能更好地进行测量。有谁知道如何使用scipy或其他Python库轻松地做到这一点吗?
Statsmodels可以做到这一点。它们有一个基本的季节分解,也有一个普查X13调整的包装。您还可以使用rpy2访问R的一些优秀SA库。以下是statsmodels季节性分解:
import pandas as pd import statsmodels.api as sm import matplotlib.pyplot as plt pd.options.display.mpl_style = 'default' %matplotlib inline dta = sm.datasets.co2.load_pandas().data.resample("M").fillna(method="ffill") res = sm.tsa.seasonal_decompose(dta) fig = res.plot() fig.set_size_inches(10, 5) plt.tight_layout()
http://statsmodels.sourceforge.net/0.6.0/release/version0.6.html
没有神奇的python库可以为您做季节性调整。做这种事情的应用程序往往是rather large。
你需要计算出数学yourself,然后使用scipy为你计算其余的。
现在有一个包,似乎正是你要找的!查看seasonal包,这里是link。我个人觉得它非常有用,不知道别人怎么想。
seasonal
Statsmodels可以做到这一点。它们有一个基本的季节分解,也有一个普查X13调整的包装。您还可以使用rpy2访问R的一些优秀SA库。以下是statsmodels季节性分解:
http://statsmodels.sourceforge.net/0.6.0/release/version0.6.html
没有神奇的python库可以为您做季节性调整。做这种事情的应用程序往往是rather large。
你需要计算出数学yourself,然后使用scipy为你计算其余的。
现在有一个包,似乎正是你要找的!查看
seasonal
包,这里是link。我个人觉得它非常有用,不知道别人怎么想。相关问题 更多 >
编程相关推荐