Skip to content

[Python] Fix DataFrame Series.value_counts with bins - #40505

Open
anishmehta24 wants to merge 1 commit into
apache:masterfrom
anishmehta24:fix/value-counts-bins
Open

anishmehta24 wants to merge 1 commit into
apache:masterfrom
anishmehta24:fix/value-counts-bins

Conversation

@anishmehta24

Copy link
Copy Markdown
Contributor

Fixes #40503

[self._expr] was inside the lambda in the bins branch of value_counts, so ComputedExpression was created without its args and always raised a TypeError. This moves it out, and builds the proxy from a one-element Series since pandas can't compute bins for the empty proxy. Added a test to frames_test.py and a CHANGES.md entry.

Written with help from Claude.

@codecov

codecov Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.72%. Comparing base (76f6e6d) to head (d59b30a).
⚠️ Report is 139 commits behind head on master.

Additional details and impacted files
@@              Coverage Diff              @@
##             master   #40505       +/-   ##
=============================================
+ Coverage     56.16%   79.72%   +23.55%     
=============================================
  Files          1124      487      -637     
  Lines        178336    82289    -96047     
  Branches       1489        0     -1489     
=============================================
- Hits         100170    65603    -34567     
+ Misses        75645    16686    -58959     
+ Partials       2521        0     -2521     
Flag Coverage Δ
go ?
java ?
python 79.72% <100.00%> (+0.16%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 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.

@github-actions

Copy link
Copy Markdown
Contributor

Assigning reviewers:

R: @shunping for label python.

Note: If you would like to opt out of this review, comment assign to next reviewer.

Available commands:

  • stop reviewer notifications - opt out of the automated review tooling
  • remind me after tests pass - tag the comment author after tests pass
  • waiting on author - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)

The PR bot will only process comments in the main thread (not review comments).

@shunping shunping left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Could you rebase to the master and resolve the conflict? Thanks!

@anishmehta24

Copy link
Copy Markdown
Contributor Author

Rebased on master and kept both CHANGES.md entries. Thanks!

@anishmehta24
anishmehta24 force-pushed the fix/value-counts-bins branch from 8d6ee0d to d59b30a Compare October 12, 2026 22:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: DataFrame API Series.value_counts(bins=...) always fails with TypeError

2 participants