-
-
Notifications
You must be signed in to change notification settings - Fork 18.2k
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
BUG/API: Fix operating with timedelta64/pd.offsets on rhs of a datelike series/index #4534
Conversation
….DateOffset when operating with datetimes
…ta64 not working the same TST: add in @cpcloud tests related to GH4135
…ipled by an integer series
TST: add tests/catch for non-absolute DateOffsets in timedelta operations
bombs away |
BUG/API: Fix operating with timedelta64/pd.offsets on rhs of a datelike series/index
👍 |
@jreback which of these should be allowed with rops? E.g., clearly okay to do |
I think the reversals are somewhat handled (e.g. lhs of int and rhs of td is ok when doing mul) |
@jreback so the problem is that, with how the arithmetic functions (and
get the same call signature for # earlier
if r_op:
external_op = op
op = lambda x, y: external_op(y, x)
if r_op:
rvalues, lvalues = self, other
else:
lvalues, rvalues = self, other and then flip the ops when they actually get passed to the operation (since all
That should make all the checks work for it, right? |
can we add a flag to the wrapper to indicate if its a reversed arg op? (eg. True for radd and False for add)? |
@jreback yeah, that's what I outlined. There's already a flag (since it gets the name), it's just:
and it happens when the method is bound, not when it's called, so the cost of the check is minimal. |
@jtratner i c now....getting late! I think if you see a reversed op, do:
because the timedelta/datetime compuations are very sensitive to the type of the lhs operator (even before values are calculated), e.g. lhs=td, rhs=integer -> radd -> lhs=integer, rhs=td will blow up as don't know how to deal wit this, its required to have the td on the lhs (I mean it could deal with it but just easier this way) |
@jreback can't do that, because the other could be a scalar or something, right? |
@jreback figured it out, it's all good |
great! |
aren't the
|
@jreback yes, but the call signature is the same both times
|
ahh...so that's ok (in this case then), but |
yes (because name is used to set |
gotcha FYI minor rebasing to master of series2, (incorporates json changes) and some doc cleanups |
closes #4532
closes #4134
closes #4135
closes #4521
Timedeltas can be converted to other ‘frequencies’ by dividing by another timedelta.
to days
to seconds
Dividing or multiplying a timedelta64[ns] Series by an integer or integer Series yields a float64 dtyped Series.