Skip to content

Fix pandas 3.0 compatibility in MarginalEffectsPlot _prepare_data#5118

Open
shrutipatel31 wants to merge 1 commit intofacebook:mainfrom
shrutipatel31:export-D99107237
Open

Fix pandas 3.0 compatibility in MarginalEffectsPlot _prepare_data#5118
shrutipatel31 wants to merge 1 commit intofacebook:mainfrom
shrutipatel31:export-D99107237

Conversation

@shrutipatel31
Copy link
Copy Markdown
Contributor

Summary:
Fix pandas 3.0 compatibility in MarginalEffectsPlot _prepare_data

Similar changes done in D91825190. Under pandas 3.0, future.infer_string=True is the default, which causes StringDtype inference on arm parameter DataFrames.
This breaks the downstream marginal_effects() call in statstools.py,
producing a KeyError on the result DataFrame's column selection.

Apply the _use_object_dtype_for_strings decorator to _prepare_data,
matching the pattern already used at 11 other callsites in the Ax codebase
(e.g. _extract_arm_data, _extract_observation_data in data_utils.py).

Fixes test_marginal_effects::test_compute_adhoc failure in GitHub Actions CI where the latest pandas (3.0+) is installed from PyPI.

Differential Revision: D99107237

Summary:
Fix pandas 3.0 compatibility in MarginalEffectsPlot _prepare_data

Similar changes done in D91825190. Under pandas 3.0, `future.infer_string=True` is the default, which causes `StringDtype` inference on arm parameter DataFrames.
This breaks the downstream `marginal_effects()` call in `statstools.py`,
producing a `KeyError` on the result DataFrame's column selection.

Apply the `_use_object_dtype_for_strings` decorator to `_prepare_data`,
matching the pattern already used at 11 other callsites in the Ax codebase
(e.g. `_extract_arm_data`, `_extract_observation_data` in `data_utils.py`).

Fixes `test_marginal_effects::test_compute_adhoc` failure in GitHub Actions CI where the latest pandas (3.0+) is installed from PyPI.

Differential Revision: D99107237
@meta-cla meta-cla bot added the CLA Signed Do not delete this pull request or issue due to inactivity. label Apr 1, 2026
@meta-codesync
Copy link
Copy Markdown

meta-codesync bot commented Apr 1, 2026

@shrutipatel31 has exported this pull request. If you are a Meta employee, you can view the originating Diff in D99107237.

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.40%. Comparing base (6cebd1c) to head (476b867).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5118      +/-   ##
==========================================
- Coverage   96.40%   96.40%   -0.01%     
==========================================
  Files         613      613              
  Lines       68142    68144       +2     
==========================================
+ Hits        65694    65695       +1     
- Misses       2448     2449       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

Labels

CLA Signed Do not delete this pull request or issue due to inactivity. fb-exported meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants