Skip to content

Commit

Permalink
#46 start working on anomalize
Browse files Browse the repository at this point in the history
  • Loading branch information
mdancho84 committed Oct 4, 2023
1 parent cfcda7e commit 382c3b5
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## pytimetk version 0.1.0.9000 (in development)

New Functions:

- `augment_expanding()`
- `get_frequency()`

## pytimetk version 0.1.0 (2023-10-02)

Initial release. This release includes the following features:
Expand Down
26 changes: 26 additions & 0 deletions src/pytimetk/core/anomaly.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import pandas as pd

from pytimetk import ts_summary

from statsmodels.tsa.seasonal import STL

def stl_decompose(data, date_column, value_column, freq, trend, **kwargs):

summary_df = ts_summary(data, date_column)

# Decompose the time series
stl = STL(data[value_column], freq=freq, **kwargs)
res = stl.fit()

# Build the dataframe containing the decomposed components
df = pd.DataFrame({
'date': data[date_column],
'value': data[value_column],
'trend': res.trend,
'seasonal': res.seasonal,
'residual': res.resid
})

return df


0 comments on commit 382c3b5

Please sign in to comment.