Skip to content

feat: Add IntervalIndex support to bigframes.pandas.cut #254

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Dec 18, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add bins <= 0 error in CutOp
  • Loading branch information
Genesis929 committed Dec 12, 2023
commit 1390445b29dcceef3f82b58597815e89725df023
2 changes: 2 additions & 0 deletions bigframes/operations/aggregations.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,8 @@ def skips_nulls(self):
class CutOp(WindowOp):
def __init__(self, bins: typing.Union[int, pd.IntervalIndex]):
if isinstance(bins, int):
if not bins > 0:
raise ValueError("`bins` should be a positive integer.")
self._bins_int = bins
Copy link
Contributor

@shobsi shobsi Dec 12, 2023

Choose a reason for hiding this comment

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

This might be a good place to check bins>0. I know we are doing it in the cut method, but this is a public class as well, and also contains the business logic if-else at line 243.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done, added a check here.

self._bins = dtypes.literal_to_ibis_scalar(bins, force_dtype=Int64Dtype())
else:
Expand Down