Skip to content

Fix FutureWarning for observed parameter in groupby#3901

Open
nuryagli wants to merge 1 commit intomwaskom:masterfrom
nuryagli:fix-futurewarning-observed-parameter
Open

Fix FutureWarning for observed parameter in groupby#3901
nuryagli wants to merge 1 commit intomwaskom:masterfrom
nuryagli:fix-futurewarning-observed-parameter

Conversation

@nuryagli
Copy link

Summary

Fix FutureWarning triggered when using relplot with the units parameter on categorical data.

Closes #3891

Changes

Added observed=False parameter to groupby("units") call in relational.py (line 313) to explicitly set the behavior and suppress the FutureWarning from pandas 2.2.0+.

Details

Since pandas 2.2.0, the default value of observed in groupby is deprecated and will change to True in a future version. This PR explicitly sets observed=False to maintain the current behavior and eliminate the warning.

Before:

for _, unit_data in sub_data.groupby("units"):

After:

for _, unit_data in sub_data.groupby("units", observed=False):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FutureWarning from observed parameter of pandas' groupby used in relplot

1 participant