Related to Fun with Pandas `rolling_apply` and TypeError and Using rolling_apply on a DataFrame object
Suppose F is a function that returns a function and df is a Series with a datetime index.
The following seems to work:
df.groupby(pandas.TimeGrouper('10d')).apply(F)
while the following results in a TypeError as rolling_apply seems to expect floats as return values.
pandas.rolling_apply(df, 10, F)
I actually want the latter as I want to groupby each window of 10 available days and not the available data from each 10-day window as I think TimeGrouper does.
Is there a direct way to do this using some other function?
For a concrete example, this appears to be working:
from statsmodels.tools.tools import ECDF
s = pandas.Series(randn(1000))
s.index = pandas.date_range('2012-01-01', periods=s.shape[0], freq='D')
f = s.groupby(pandas.TimeGrouper('30D')).apply(ECDF)
f.apply(lambda x: x(0.1)).head()