Skip to content

Rolling groupby should not maintain the by column in the resulting DataFrame #32262

Closed
@andreas-vester

Description

@andreas-vester

When performing a rolling operation on a groupby object, the index level will be incorrectly maintained in the dataframe.

import numpy as np
import pandas as pd

df = pd.DataFrame({'idx_L1': ['Level_1'] * 10 + ['Level_2'] * 10 + ['Level_3'] * 10,  
                   'idx_L2': ([1] * 5 + [2] * 5 + [3] * 5) * 2,  
                   'vals': np.arange(30)})

df.groupby(['idx_L1', 'idx_L2']).rolling(3).sum()

This issue has been discussed in #14013.

It has been closed eventhough the bug still exists in v1.01.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions