This repository was archived by the owner on May 7, 2026. It is now read-only.
fix: fix pandas.cut errors with empty bins#1499
Merged
chelsea-lin merged 3 commits intomainfrom Mar 18, 2025
Merged
Conversation
sycai
reviewed
Mar 17, 2025
| window_spec=window_specs.unbound(), | ||
| ) | ||
| op = agg_ops.CutOp(bins, right=right, labels=labels) | ||
| if isinstance(bins, typing.Iterable) and len(as_index) == 0: |
Contributor
There was a problem hiding this comment.
Could we directly return the [pd.NA] * len(x) result from the elif branch len(list(bins)) == 0?
In that case we don't need the additional if-else branch at the bottom of the function, and the logic looks more straightforward. Plus, we don't need to alter the behavior of CutOp.output_type() in aggregations.py too
Contributor
Author
There was a problem hiding this comment.
All of the elif branch can turn to the [pd.NA] * len(x) result, such as
- 1st elif for
pd.IntervalIndex.from_tuples([]). - 2nd elif for
[] - 4st elif for
[1]
Because of that,CutOp.output_type()might return different result for each case above.
Fixes internal issue 403638910 🦕