-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
implement constructors for TimedeltaArray, DatetimeArray #21803
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
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.
minor comments
if is_int: | ||
val = getitem(key) | ||
return self._box_func(val) | ||
else: |
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.
don't need the else here
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.
This is the existing __getitem__
moved verbatim. Can de-indent in the next pass.
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!
return result | ||
|
||
def __new__(cls, values, freq=None, tz=None): | ||
if (freq is not None and not isinstance(freq, DateOffset) and |
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.
this condition could actually be handled to by to_offset
(future PR) (except for the not-None part)
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.
Yah, I anticipate most of the existing constructors will be moved from the Index subclasses to the Array subclasses; for now I just need something that works for the cases that are called internally.
Just updated to de-conflict changes to tz_convert/tz_localize docstrings. |
Codecov Report
@@ Coverage Diff @@
## master #21803 +/- ##
==========================================
- Coverage 91.95% 91.9% -0.05%
==========================================
Files 160 160
Lines 49858 49902 +44
==========================================
+ Hits 45845 45864 +19
- Misses 4013 4038 +25
Continue to review full report at Codecov.
|
thanks @jbrockmendel |
Implements AttributesMixin since this is a pattern we might want to formalize.
The
_simple_new
that this implements for TimedeltaArray and DatetimeArray are pretty close to the "full" versions in the Index classes. The__new__
methods though are very much stripped down for the now.With these in place we get to move
tz_convert
andtz_localize
. Could do a bunch more if I wasn't too much of a wuss to do it all in one go.