You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "eschutho (via GitHub)" <gi...@apache.org> on 2026/07/13 16:32:48 UTC

[PR] fix(pandas_postprocessing): avoid FutureWarning for mean/median in boxplot [superset]

eschutho opened a new pull request, #42004:
URL: https://github.com/apache/superset/pull/42004

   ## What
   Production logs showed a high-volume pandas `FutureWarning`:
   
   > The provided callable <function mean/median at 0x...> is currently using SeriesGroupBy.mean/median. In a future version of pandas, the provided callable will be used directly. To keep current behavior pass the string "mean"/"median" instead.
   
   This exact class of warning was previously addressed in #41025, which taught `_get_aggregate_funcs` (in `pandas_postprocessing/utils.py`) to pass the string operator name (e.g. `"mean"`) instead of a raw numpy callable when possible, avoiding the ambiguity pandas warns about.
   
   However, `pandas_postprocessing/boxplot.py` builds its own `operators` dict independently and was passing `np.mean` / `np.median` directly as the `operator` value. Since `_get_aggregate_funcs` special-cases callables first (`if callable(operator): aggfunc = operator`), this bypassed the #41025 fix entirely — so every boxplot chart post-processing call kept emitting the warning. Boxplot charts are common, which is why this was showing up frequently in prod logs.
   
   ## Change
   In `boxplot.py`, pass `"mean"` / `"median"` as string literals instead of `np.mean` / `np.median`, so they route through the same string-based path `_get_aggregate_funcs` already uses. `np.ma.count` is left untouched, since it intentionally differs from pandas' `"count"` (it includes NaNs).
   
   ## No behavior change
   Verified empirically that the string and callable forms produce identical output for `mean`/`median` on the currently pinned pandas range (`>=2.1.4,<2.4`). Added a regression test that also guards against a real (not just cosmetic) divergence: on pandas ≥3.0, `np.median` on a group containing NaNs returns `NaN` (no `skipna`), while the `"median"` string aggregator still skips NaNs — so this also prevents a silent numeric regression whenever the pandas pin is eventually bumped.
   
   ## Test plan
   - Added `test_boxplot_mean_median_no_future_warning` in `tests/unit_tests/pandas_postprocessing/test_boxplot.py`: asserts no `FutureWarning` is raised and that `mean`/`median` values match a plain `df.groupby(...).agg(["mean", "median"])` call.
   - Ran the full `tests/unit_tests/pandas_postprocessing/` suite locally (108 tests, all passing).
   - Ran `ruff check` / `ruff format` and `mypy` on the changed file — no new issues introduced (two pre-existing, unrelated mypy errors on lines 103-104 remain untouched).


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(pandas_postprocessing): avoid FutureWarning for mean/median in boxplot [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #42004:
URL: https://github.com/apache/superset/pull/42004#issuecomment-4960251809

   AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(pandas_postprocessing): avoid FutureWarning for mean/median in boxplot [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #42004:
URL: https://github.com/apache/superset/pull/42004#issuecomment-4960268020

   <!-- Bito Reply -->
   The suggestion to add an explicit return type annotation to the new test function is correct and follows standard Python type-hinting practices. You can resolve this by updating the function signature to include `-> None`.
   
   Here is the corrected function signature:
   
   ```python
   def test_boxplot_mean_median_no_future_warning() -> None:
       """mean/median must be passed as strings (not np.mean/np.median) to
       GroupBy.agg, else pandas raises a FutureWarning. Also verify the values
       match a plain pandas groupby, since the string and callable forms could
       silently diverge on a future pandas version."""
   ```
   
   There are no other review comments available in the provided context to check. Would you like me to proceed with any other tasks?
   
   **tests/unit_tests/pandas_postprocessing/test_boxplot.py**
   ```
   def test_boxplot_mean_median_no_future_warning() -> None:
       """mean/median must be passed as strings (not np.mean/np.median) to
       GroupBy.agg, else pandas raises a FutureWarning. Also verify the values
       match a plain pandas groupby, since the string and callable forms could
       silently diverge on a future pandas version."""
   ```


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(pandas_postprocessing): avoid FutureWarning for mean/median in boxplot [superset]

Posted by "eschutho (via GitHub)" <gi...@apache.org>.
eschutho merged PR #42004:
URL: https://github.com/apache/superset/pull/42004


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(pandas_postprocessing): avoid FutureWarning for mean/median in boxplot [superset]

Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #42004:
URL: https://github.com/apache/superset/pull/42004#issuecomment-4960298004

   ## [Codecov](https://app.codecov.io/gh/apache/superset/pull/42004?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :x: Patch coverage is `0%` with `1 line` in your changes missing coverage. Please review.
   :white_check_mark: Project coverage is 56.13%. Comparing base ([`8f75f1a`](https://app.codecov.io/gh/apache/superset/commit/8f75f1a353dbcb8eafff4e98fbfb19cf6b33ca44?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`179c183`](https://app.codecov.io/gh/apache/superset/commit/179c18369a89b037b10efe087fa95fcf4d7956ee?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   
   | [Files with missing lines](https://app.codecov.io/gh/apache/superset/pull/42004?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
   |---|---|---|
   | [superset/utils/pandas\_postprocessing/boxplot.py](https://app.codecov.io/gh/apache/superset/pull/42004?src=pr&el=tree&filepath=superset%2Futils%2Fpandas_postprocessing%2Fboxplot.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvdXRpbHMvcGFuZGFzX3Bvc3Rwcm9jZXNzaW5nL2JveHBsb3QucHk=) | 0.00% | [1 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/42004?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   > :exclamation:  There is a different number of reports uploaded between BASE (8f75f1a) and HEAD (179c183). Click for more details.
   > 
   > <details><summary>HEAD has 11 uploads less than BASE</summary>
   >
   >| Flag | BASE (8f75f1a) | HEAD (179c183) |
   >|------|------|------|
   >|python|11|2|
   >|presto|2|1|
   >|hive|2|1|
   ></details>
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@            Coverage Diff             @@
   ##           master   #42004      +/-   ##
   ==========================================
   - Coverage   65.01%   56.13%   -8.88%     
   ==========================================
     Files        2744     2744              
     Lines      153571   153571              
     Branches    35212    35212              
   ==========================================
   - Hits        99842    86213   -13629     
   - Misses      51822    66532   +14710     
   + Partials     1907      826    -1081     
   ```
   
   | [Flag](https://app.codecov.io/gh/apache/superset/pull/42004/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [hive](https://app.codecov.io/gh/apache/superset/pull/42004/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `39.06% <0.00%> (ø)` | |
   | [mysql](https://app.codecov.io/gh/apache/superset/pull/42004/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [postgres](https://app.codecov.io/gh/apache/superset/pull/42004/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [presto](https://app.codecov.io/gh/apache/superset/pull/42004/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `41.05% <0.00%> (ø)` | |
   | [python](https://app.codecov.io/gh/apache/superset/pull/42004/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `41.11% <0.00%> (-18.26%)` | :arrow_down: |
   | [sqlite](https://app.codecov.io/gh/apache/superset/pull/42004/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [unit](https://app.codecov.io/gh/apache/superset/pull/42004/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
   </details>
   
   [:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/superset/pull/42004?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
   - :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </details>


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(pandas_postprocessing): avoid FutureWarning for mean/median in boxplot [superset]

Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on code in PR #42004:
URL: https://github.com/apache/superset/pull/42004#discussion_r3572396656


##########
tests/unit_tests/pandas_postprocessing/test_boxplot.py:
##########
@@ -44,6 +47,27 @@ def test_boxplot_tukey():
     assert len(df) == 4
 
 
+def test_boxplot_mean_median_no_future_warning():

Review Comment:
   **Suggestion:** Add an explicit return type annotation to this new test function signature (for example, `-> None`) to satisfy the type-hint requirement for newly introduced Python functions. [custom_rule]
   
   **Severity Level:** Minor 🧹
   <details>
   <summary><b>Why it matters? ⭐ </b></summary>
   
   The new test function is missing an explicit return type annotation. Under the Python type-hint rule, newly introduced functions should be annotated, so `-> None` should be added here.
   </details>
   <details>
   <summary><b>Rule source 📖 </b></summary>
   
   .cursor/rules/dev-standard.mdc (line 28)
   </details>
   
   [![Fix in Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=6bd8076fff6749a08f18133ce1187130&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) [![Fix in VSCode Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=6bd8076fff6749a08f18133ce1187130&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** tests/unit_tests/pandas_postprocessing/test_boxplot.py
   **Line:** 50:50
   **Comment:**
   	*Custom Rule: Add an explicit return type annotation to this new test function signature (for example, `-> None`) to satisfy the type-hint requirement for newly introduced Python functions.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
   Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
   ```
   </details>
   <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42004&comment_hash=ee0d4b0405931f8059bc93e562fccdc1f4e94df4e9c5f431a1b82a97c953177e&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42004&comment_hash=ee0d4b0405931f8059bc93e562fccdc1f4e94df4e9c5f431a1b82a97c953177e&reaction=dislike'>👎</a>



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org