-
Notifications
You must be signed in to change notification settings - Fork 168
refactor: Add CompliantColumn
#2967
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
Conversation
Only tweak was `unique` having a default, but it isn't used by `pyarrow`, `pandas` - only `polars`
Was a bit more involved since - 4 rhs bin ops and `is_between` aren't defined at this level - polars was missing even more
Eventually we can just require the two `_with_binary*` have defs and then avoid repeating each dunder in every backend
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @dangotbanned this looks promising 🎉 I left a couple of minor comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really nice one! 🎉
| def is_between( | ||
| self, lower_bound: Self, upper_bound: Self, closed: ClosedInterval | ||
| ) -> Self: | ||
| if closed == "left": | ||
| return (self >= lower_bound) & (self < upper_bound) | ||
| if closed == "right": | ||
| return (self > lower_bound) & (self <= upper_bound) | ||
| if closed == "none": | ||
| return (self > lower_bound) & (self < upper_bound) | ||
| return (self >= lower_bound) & (self <= upper_bound) | ||
|
|
||
| def is_duplicated(self) -> Self: | ||
| return ~self.is_unique() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could fix Series.rename + Series.shape in the same way
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be a really nice side effect. I know we are not too invested at the moment with the api completeness, but these changes are low hanging fruit, and might simplify a lot the logic there (api completeness) without the need of handling additional special cases
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could fix
Series.rename+Series.shapein the same way
Thinking back, I'm not super concerned about these two for now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @dangotbanned - I am pretty much onboarded with these changes. I will wait for @MarcoGorelli approval on this one though!
Just for context, are you considering this PR a requirement for #2962 or viceversa or neither 😂?
| def is_between( | ||
| self, lower_bound: Self, upper_bound: Self, closed: ClosedInterval | ||
| ) -> Self: | ||
| if closed == "left": | ||
| return (self >= lower_bound) & (self < upper_bound) | ||
| if closed == "right": | ||
| return (self > lower_bound) & (self <= upper_bound) | ||
| if closed == "none": | ||
| return (self > lower_bound) & (self < upper_bound) | ||
| return (self >= lower_bound) & (self <= upper_bound) | ||
|
|
||
| def is_duplicated(self) -> Self: | ||
| return ~self.is_unique() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be a really nice side effect. I know we are not too invested at the moment with the api completeness, but these changes are low hanging fruit, and might simplify a lot the logic there (api completeness) without the need of handling additional special cases
Now that #2962 has merged, this part of the plan is possible (#2962 (comment))
Well we've done it this way round now regardless 😄 |
from a look this seems good, i'm running out of time for the day but if you're happy with it feel free to ship it, thanks both! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks again for this refactor @dangotbanned 🙏🏼



What type of PR is this? (check all applicable)
Related issues
{Expr,Series}.is_close#2962{Expr,Series}.is_close#2962 (comment){Expr,Series}.is_close#2962 (comment)Checklist
If you have comments or can explain your changes, please do so below
Creates a common parent protocol for
Compliant{Expr,Series}, spec-ing their shared partsThe diff isn't huge here, but
it'll shrinkit shrinksis_closeand allow us to implement more features in a similar way