kimjune01 opened a new pull request, #40064:
URL: https://github.com/apache/superset/pull/40064
### SUMMARY
Fixes #36530
`boxplot()` and `histogram()` in `superset/utils/pandas_postprocessing/`
trigger pandas `SettingWithCopyWarning` during type coercion.
Two targeted fixes:
- **boxplot.py**: `df[column] = to_numeric(...)` assigns through a potential
view. Changed to `df.loc[:, column]`.
- **histogram.py**: `dropna()` can return a view, so the subsequent
`to_numeric` assignment warns. Appended `.copy()` to the `dropna()` call.
Also fixed a pre-existing test mutation bug where
`test_boxplot_type_coercion` modified the shared `names_df` without `.copy()`.
Added two regression tests that promote `SettingWithCopyWarning` to an error
and verify neither function raises it.
### TESTING INSTRUCTIONS
```bash
pytest tests/unit_tests/pandas_postprocessing/test_boxplot.py -v
pytest tests/unit_tests/pandas_postprocessing/test_histogram.py -v
```
New tests:
- `test_boxplot_no_setting_with_copy_warning`
- `test_histogram_no_setting_with_copy_warning`
Both use `warnings.simplefilter("error", SettingWithCopyWarning)` to catch
regressions. Existing tests continue to pass.
### ADDITIONAL INFORMATION
- [x] Has associated issue: #36530
- [ ] Required feature flags:
- [ ] Changes UI
- [ ] Includes DB Migration
- [ ] Introduces new feature or API
- [ ] Removes existing feature or API
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]