-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
REF: Stop mixing DTA/TDA into DTI/TDI #24476
Conversation
Codecov Report
@@ Coverage Diff @@
## master #24476 +/- ##
==========================================
- Coverage 92.32% 92.32% -0.01%
==========================================
Files 166 166
Lines 52298 52359 +61
==========================================
+ Hits 48285 48339 +54
- Misses 4013 4020 +7
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #24476 +/- ##
==========================================
- Coverage 92.32% 92.31% -0.01%
==========================================
Files 166 166
Lines 52328 52379 +51
==========================================
+ Hits 48310 48354 +44
- Misses 4018 4025 +7
Continue to review full report at Codecov.
|
pandas/core/indexes/datetimes.py
Outdated
|
||
return cls(dtarr, name=name) | ||
dtarr = DatetimeArray._generate_range( | ||
start, end, periods, |
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.
should the warning message actually be in DTA._generate_range?
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.
No, the non-deprecated way it gets called is via date_range
pandas/core/indexes/datetimes.py
Outdated
@@ -286,16 +281,16 @@ def __new__(cls, data=None, | |||
verify_integrity = True | |||
|
|||
if data is None: | |||
dtarr = DatetimeArray._generate_range( |
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.
Can this change be (partially) reverted? We want the warning after the array creation, in case the array creation raises an exception.
I'm not sure whether you want cls(...)
or cls._simple_new
right now. Probably simple_new.
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 want the warning after the array creation, in case the array creation raises an exception.
Makes sense, will change.
I'm not sure whether you want cls(...) or cls._simple_new right now. Probably simple_new
_simple_new. It's performant and correct regardless of what becomes of the discussed changes in DTA/TDA constructors/validation.
pandas/core/indexes/datetimes.py
Outdated
_has_same_tz = ea_passthrough("_has_same_tz") | ||
__array__ = ea_passthrough("__array__") | ||
|
||
def round(self, freq, ambiguous='raise', nonexistent='raise'): |
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.
It looks like you can (maybe?) remove road, floor, and ciel. I haven't run the tests, but a manual example works.
They should be dispatched via DatetimeArray._datetimelike_methods
.
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.
excellent, I'll give it a shot
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.
did this work out?
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.
tentatively yes. we'll see if the CI agrees in a bit
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.
yep
|
||
self._freq = to_offset(value) | ||
|
||
def __getitem__(self, key): |
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.
In #24024 we move __getitem__
to the base DatetimeIndexOpsMixin
and DatetimeArrayMixin
. That seems relatively easy to do if we're already changing __getitem__
here and in TimedeltaIndex, but it may not be possible yet.
can you merge master |
lgtm. @TomAugspurger |
Thanks. I'll merge this into #24024. |
|
||
_timezone = cache_readonly(DatetimeArray._timezone.fget) | ||
is_normalized = cache_readonly(DatetimeArray.is_normalized.fget) | ||
_resolution = cache_readonly(DatetimeArray._resolution.fget) | ||
|
||
strftime = ea_passthrough("strftime") |
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 removed the docstring. Is there a TODO / issue to add it back?
return type(self)(result, name=self.name) | ||
|
||
@property | ||
def freq(self): # TODO: get via eadata |
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.
The same here, this had a docstring before
* implement _index_data parts of pandas-dev#24024 * implement _eadata, dispatch arithmetic methods to it * dont mix DatetimeLikeArrayMixin into DatetimeIndexOpsMixin * dont inherit TimedeltaIndex from TimedeltaArray * dont inherit from DatetimeArray * use ea_passthrough * remove previously-overriden overridings * stop double-mixing * stop over-writing * handle+test object arrays * Remove unused import * flake8 fixup * edits per comments
* implement _index_data parts of pandas-dev#24024 * implement _eadata, dispatch arithmetic methods to it * dont mix DatetimeLikeArrayMixin into DatetimeIndexOpsMixin * dont inherit TimedeltaIndex from TimedeltaArray * dont inherit from DatetimeArray * use ea_passthrough * remove previously-overriden overridings * stop double-mixing * stop over-writing * handle+test object arrays * Remove unused import * flake8 fixup * edits per comments
part of the #24024 process
along the way fixes+tests
DTA.__eq__(ndarray[object])
bug