-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
implement TimedeltaArray asm8, to_timedelta64 #23205
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
Changes from all commits
fa5e161
77788b9
3635fdb
e426ff6
0ab9cce
b252ac8
06c147e
a1e1127
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -355,6 +355,31 @@ def to_pytimedelta(self): | |
""" | ||
return tslibs.ints_to_pytimedelta(self.asi8) | ||
|
||
def to_timedelta64(self): | ||
""" | ||
Return numpy array with timedelta64[ns] dtype | ||
|
||
Returns | ||
------- | ||
ndarray[timedelta64[ns]] | ||
|
||
Notes | ||
----- | ||
This returns a view on self, not a copy. | ||
|
||
See also | ||
-------- | ||
Timedelta.to_timedelta64 | ||
""" | ||
return self.asi8.view('m8[ns]') | ||
|
||
@property | ||
def asm8(self): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we need both There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we were starting fresh I would say no, but as it is I think consistency with the scalar type is really worthwhile. (and to your point aboe DatetimeIndex should have a |
||
""" | ||
Vectorized analogue of Timedelta.asm8 | ||
""" | ||
return self.to_timedelta64() | ||
|
||
days = _field_accessor("days", "days", | ||
" Number of days for each element. ") | ||
seconds = _field_accessor("seconds", "seconds", | ||
|
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.
you are going a little bit in circles here, as
asi8
itself is alreadyself.values.view('i8')
?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 find
asi8
much more explicit than alues (BTW as I mentioned to jreback the "v" key on my keyboard is sticky; I'm going to stop copy-pasting and let you guys infer the missing letter for a while).