Repository navigation
[Repo Assist] fix(interpreters): add observed=True to groupby in ConfounderDistributionInterpreter - #1755
Draft
github-actions[bot] wants to merge 1 commit into
Conversation
…tionInterpreter pandas >= 2.2 emits FutureWarning when groupby() is called on a DataFrame that contains categorical columns without the observed=True keyword argument; pandas 3.x will change the default. ConfounderDistributionInterpreter.interpret() performs two groupby calls on [var_name, treatment_variable] pairs without observed=True. Since this interpreter is only used with discrete/categorical variables (the 'continuous' path raises NotImplementedError), this warning fires on every call. Fix: add observed=True to both groupby calls. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
75 tasks
62 tasks
Contributor
Author
|
This PR is stale because it has been open for 60 days with no activity. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 This is an automated PR from Repo Assist, an AI assistant for this repository.
Problem
ConfounderDistributionInterpreter.interpret()callsgroupby()twice withoutobserved=True:Since this interpreter is only used with
var_type="discrete"(the"continuous"path raisesNotImplementedError), the grouped columns are always discrete/categorical. pandas ≥ 2.2 emits aFutureWarningfor every such call, and pandas 3.x changed the default fromobserved=Falsetoobserved=True.Without
observed=True, when any of the grouped columns is a pandasCategorical, the result can include empty groups for categories not present in the data, inflating the count/weight plots with spurious zero bars.Fix
Add
observed=Trueto both groupby calls.Relation to existing PRs
PR #1732 fixed analogous
groupbycalls in:propensity_balance_interpreter.pypropensity_score_stratification_estimator.pydistance_matching_estimator.pyThis PR completes the fix for the remaining
ConfounderDistributionInterpreter.Test Status
The existing interpreter tests pass. Direct tests for this interpreter require matplotlib and propensity score weights, so they are marked
@pytest.mark.advanced.Linting and formatting checks pass (
poe lint,poe format_check).