We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
I have confirmed this bug exists on the main branch of pandas.
import numpy as np import pandas as pd n_rows = 1_000 group_size = 10 n_random_cols = 200 data = {"id": np.repeat(np.arange(n_rows // group_size), group_size)} for i in range(n_random_cols): data[f"col_{i}"] = np.random.randn(n_rows) df = pd.DataFrame(data) # PerformanceWarning when as_index is False named_agg_without_index_warning_df = ( df .groupby('id', as_index=False) .agg(**{ column: pd.NamedAgg(column=column, aggfunc="mean") for column in df.columns if column != "id" }) ) # no warnings when as_index is True named_agg_with_index_ok_df = ( df .groupby('id', as_index=True) .agg(**{ column: pd.NamedAgg(column=column, aggfunc="mean") for column in df.columns if column != "id" }) ) # no warnings when using dict agg no matter what as_index is dict_agg_ok_df = ( df .groupby('id', as_index=False) .agg({ column: "mean" for column in df.columns if column != "id" }) )
there is an inconsistent behavior (PerformanceWarning) of agg when as_index is True/False. Please refer to the example above.
as_index
No PerformanceWarning is raised when as_index=False
PerformanceWarning
as_index=False
v2.3.0
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Pandas version checks
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
Issue Description
there is an inconsistent behavior (PerformanceWarning) of agg when
as_index
is True/False. Please refer to the example above.Expected Behavior
No
PerformanceWarning
is raised whenas_index=False
Installed Versions
v2.3.0
The text was updated successfully, but these errors were encountered: