As title says I can't run this code:
def simple_map(x):
y = seasonal_decompose(x,model='additive',extrapolate_trend='freq',period=7,two_sided=False)
return y.trend
b.map_partitions(simple_map,meta=b).compute()
where b is a dask DataFrame with a datetime as index and some series of float as columns and seasonal_decompose is the statsmodel one.
This is what I get:
Index(...) must be called with a collection of some kind, 'seasonal' was passed
If I do:
b.apply(simple_map,axis=0)
Where b is a pandas DataFrame I get what I want.
Where I am wrong?
#Reproducible example:
import pandas as pd
from statsmodels.tsa.seasonal import seasonal_decompose
d = {'Val1': [3, 2,7,5], 'Val2': [2, 4,8,6]}
b=pd.DataFrame(data=d)
b=b.set_index(pd.to_datetime(['25/12/1991','26/12/1991','27/12/1991','28/12/1991']))
def simple_map(x):
y =seasonal_decompose(x,model='additive',extrapolate_trend='freq',period=2,two_sided=False)
return y.trend
b.apply(simple_map,axis=0)
Val1 Val2
1991-12-25 0.70 0.9
1991-12-26 2.10 2.7
1991-12-27 3.50 4.5
1991-12-28 5.25 6.5
This is what i want do with dask but I cannot
In fact:
import dask.dataframe as dd
c=dd.from_pandas(b, npartitions=1)
c.map_partitions(simple_map,meta=c).compute()
Produce the above appointed error.