-
Notifications
You must be signed in to change notification settings - Fork 610
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
feat: UX: improve Interval API #8165
Labels
feature
Features or general enhancements
Comments
Thanks for the issue. I think for the specific case of age and for any case where you need an integer number of some unit, give the Ideally your function could be: def dob_to_age(dob: DateValue) -> FloatingValue:
"""Convert a date of birth to an age in years (float)."""
return ibis.now().delta(dob, "days") / 365.25 The other issues are somewhat orthogonal here:
|
Let's discuss more about intervals in #8138. See #8138 (comment) for details. |
NickCrews
added a commit
to NickCrews/ibis
that referenced
this issue
Feb 1, 2024
NickCrews
added a commit
to NickCrews/ibis
that referenced
this issue
Mar 5, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is your feature request related to a problem?
I have this function
I had several annoying experiences implementing it
date.month()
. Interval uses a property. We should be consistent. I would vote for methods. Perhaps there are other places where there is this inconsistency we should consider when making this decision?unsupported operand type(s) for /: 'IntervalScalar' and 'float'
. I expect.days()
to give me anIntegerValue
, likeDate.month()
and friends.(ibis.now().date() - dob).years()
. But I get aCannot convert interval value from unit D to unit Y
with this. Which I think makes sense, because semantics to time are not strict and in some interpretations there aren't 365.25 days in a year. Not sure there is anything to do about this, but just wanted to flag this as something I'm running into. Not sure what backends do, but probably we are at their mercy and should just do what they do.Describe the solution you'd like
I think the best usage would be
(ibis.now().date() - dob).days() / 365.25
What version of ibis are you running?
main
What backend(s) are you using, if any?
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: