Skip to content
Snippets Groups Projects
Commit 25e80388 authored by Niklas Selke's avatar Niklas Selke
Browse files

Added the mean seasonal cycle calculation for deseasonalizing the data before the trend analysis.

parent 5acdc0ec
No related branches found
No related tags found
2 merge requests!5Modified the test for the 'value_count' statistic. Now all available sampling...,!3Niklas issue009 feat calculate quantile regression
......@@ -4,6 +4,8 @@ This module contains the following function:
deseasonalize - calculate the trend using the requested method
"""
import statsmodels.formula.api as smf
def deseasonalize(data):
"""Deseasonalize the data.
......@@ -13,4 +15,9 @@ def deseasonalize(data):
:return: The deseasonalized data
"""
seasonal_cycle = smf.ols(
"value~np.cos(month*2*np.pi/12)+np.sin(month*2*np.pi/12)"
"+np.cos(month*4*np.pi/12)+np.sin(month*4*np.pi/12)",
pd.DataFrame({"value": data["value"], "month": data.index.month})
).fit(method="qr").predict(pd.DataFrame({"month": range(1, 13)}))
return data
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment