I want to groupby
dask
multi-index data frame by its level
. I want to do the following pandas equivalent in dask:
df.groupby(level=0)['TARGET']\
.apply(lambda x: x.shift().rolling(min_periods=1, window=7).sum()).fillna(0)\
.reset_index(name=str(7)+"D")
The document says that dask
doesn't support pandas
level
argument. How should I tackle this problem in that case?
I can't use the column name because the column is in the index and the column index which throws the following error:
ValueError: 'CONTACT_ID' is both an index level and a column label, which is ambiguous.
Let me know if you would require data in order to be able to assist. Thanks a lot in advance.