Fix pandas 3.0 compatibility in MarginalEffectsPlot _prepare_data#5118
Open
shrutipatel31 wants to merge 1 commit intofacebook:mainfrom
Open
Fix pandas 3.0 compatibility in MarginalEffectsPlot _prepare_data#5118shrutipatel31 wants to merge 1 commit intofacebook:mainfrom
shrutipatel31 wants to merge 1 commit intofacebook:mainfrom
Conversation
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
|
@shrutipatel31 has exported this pull request. If you are a Meta employee, you can view the originating Diff in D99107237. |
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
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.
Summary:
Fix pandas 3.0 compatibility in MarginalEffectsPlot _prepare_data
Similar changes done in D91825190. Under pandas 3.0,
future.infer_string=Trueis the default, which causesStringDtypeinference on arm parameter DataFrames.This breaks the downstream
marginal_effects()call instatstools.py,producing a
KeyErroron the result DataFrame's column selection.Apply the
_use_object_dtype_for_stringsdecorator to_prepare_data,matching the pattern already used at 11 other callsites in the Ax codebase
(e.g.
_extract_arm_data,_extract_observation_dataindata_utils.py).Fixes
test_marginal_effects::test_compute_adhocfailure in GitHub Actions CI where the latest pandas (3.0+) is installed from PyPI.Differential Revision: D99107237