-
-
Notifications
You must be signed in to change notification settings - Fork 18.3k
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: Pieces broken off of #24024 #24364
Conversation
@@ -983,7 +983,7 @@ def dt64arr_to_periodarr(data, freq, tz=None): | |||
|
|||
""" | |||
if data.dtype != np.dtype('M8[ns]'): | |||
raise ValueError('Wrong dtype: %s' % data.dtype) | |||
raise ValueError('Wrong dtype: {dtype}'.format(dtype=data.dtype)) |
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.
start, end, periods, | ||
freq=freq, tz=tz, normalize=normalize, | ||
closed=closed, ambiguous=ambiguous) | ||
return cls(dtarr, name=name) |
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 think in #24024 this becomes cls._simple_new(dtarr, name=name)
. That isn't possible yet 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.
ditto below and for TimedeltaIndex
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.
Is it worth doing this now then, when we'll just need to change it again?
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 upside is that it means the diff in 24024 is just one line. I'm OK with this either way.
|
||
arr = TimedeltaArray(data, copy=True) | ||
assert arr._data is not data | ||
assert arr._data.base is not data |
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 last line is not present in the test in #24024.
@@ -246,6 +247,17 @@ def test_to_datetime_parse_timezone_keeps_name(self): | |||
|
|||
|
|||
class TestToDatetime(object): | |||
def test_to_datetime_dtarr(self): |
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 test is not in #24024, but this tests the changes in core.tools.datetimes
In terms of LOC this shaves about 5% off of 24024. Not huge, but along with searchsorted, repeat, and reductions getting broken off, these add up |
Codecov Report
@@ Coverage Diff @@
## master #24364 +/- ##
==========================================
+ Coverage 92.29% 92.29% +<.01%
==========================================
Files 162 162
Lines 51832 51834 +2
==========================================
+ Hits 47839 47841 +2
Misses 3993 3993
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #24364 +/- ##
==========================================
+ Coverage 92.29% 92.29% +<.01%
==========================================
Files 162 162
Lines 51832 51834 +2
==========================================
+ Hits 47839 47841 +2
Misses 3993 3993
Continue to review full report at Codecov.
|
Will do. |
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 would split out the hasnans change and do that separately as it needs to happen globally
(bamboo-dev) jreback@dev:~/pandas-dev$ grep -r hasnans pandas --include '*.py'|cut -d ' ' -f 1|uniq
pandas/core/arrays/timedeltas.py:
pandas/core/arrays/period.py:
pandas/core/arrays/datetimelike.py:
pandas/core/arrays/datetimes.py:
pandas/core/indexes/timedeltas.py:
pandas/core/indexes/interval.py:
pandas/core/indexes/category.py:
pandas/core/indexes/numeric.py:
pandas/core/indexes/datetimelike.py:
pandas/core/indexes/base.py:
pandas/core/dtypes/dtypes.py:
pandas/core/series.py:
pandas/core/resample.py:
pandas/core/base.py:
pandas/tests/test_lib.py:
pandas/tests/indexes/datetimes/test_ops.py:
pandas/tests/indexes/interval/test_interval.py:
pandas/tests/indexes/period/test_ops.py:
pandas/tests/indexes/multi/test_missing.py:
pandas/tests/indexes/multi/test_missing.py:def
pandas/tests/indexes/multi/test_missing.py:
pandas/tests/indexes/common.py:
pandas/tests/indexes/timedeltas/test_ops.py:
pandas/tests/indexes/test_common.py:
pandas/tests/series/test_internals.py:def
pandas/tests/series/test_internals.py:
@@ -451,7 +464,7 @@ def _isnan(self): | |||
return (self.asi8 == iNaT) | |||
|
|||
@property # NB: override with cache_readonly in immutable subclasses | |||
def hasnans(self): | |||
def _hasnans(self): |
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.
IIRC this is a general Index property, are changing this globally? (ok by me)
What do you mean by globally changing the hasnans? I don't think anyone was
suggesting changing that anywhere other than on the datelike Array classes,
where we (I) don't want them as part of the public API.
…On Fri, Dec 21, 2018 at 11:06 AM Jeff Reback ***@***.***> wrote:
***@***.**** requested changes on this pull request.
i would split out the hasnans change and do that separately as it needs to
happen globally
(bamboo-dev) ***@***.***:~/pandas-dev$ grep -r hasnans pandas --include '*.py'|cut -d ' ' -f 1|uniq
pandas/core/arrays/timedeltas.py:
pandas/core/arrays/period.py:
pandas/core/arrays/datetimelike.py:
pandas/core/arrays/datetimes.py:
pandas/core/indexes/timedeltas.py:
pandas/core/indexes/interval.py:
pandas/core/indexes/category.py:
pandas/core/indexes/numeric.py:
pandas/core/indexes/datetimelike.py:
pandas/core/indexes/base.py:
pandas/core/dtypes/dtypes.py:
pandas/core/series.py:
pandas/core/resample.py:
pandas/core/base.py:
pandas/tests/test_lib.py:
pandas/tests/indexes/datetimes/test_ops.py:
pandas/tests/indexes/interval/test_interval.py:
pandas/tests/indexes/period/test_ops.py:
pandas/tests/indexes/multi/test_missing.py:
pandas/tests/indexes/multi/test_missing.py:def
pandas/tests/indexes/multi/test_missing.py:
pandas/tests/indexes/common.py:
pandas/tests/indexes/timedeltas/test_ops.py:
pandas/tests/indexes/test_common.py:
pandas/tests/series/test_internals.py:def
pandas/tests/series/test_internals.py:
------------------------------
In pandas/core/arrays/datetimelike.py
<#24364 (comment)>:
> @@ -451,7 +464,7 @@ def _isnan(self):
return (self.asi8 == iNaT)
@Property # NB: override with cache_readonly in immutable subclasses
- def hasnans(self):
+ def _hasnans(self):
IIRC this is a general Index property, are changing this globally? (ok by
me)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#24364 (review)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABQHIs3VybVXypznl-NUsnhsqll10BnBks5u7RUFgaJpZM4ZbLQI>
.
|
This matches what I had in mind, just doing it on DTI/TDI/PI. |
You wrote DTI/TDI/PI, did you mean DTA/TDA/PA? Or do you mean aliasing
_hasnans to hasnans on the index classes? I should probably just look at
the diff :)
…On Fri, Dec 21, 2018 at 11:19 AM jbrockmendel ***@***.***> wrote:
I don't think anyone was suggesting changing that anywhere other than on
the datelike Array classes,
This matches what I had in mind, just doing it on DTI/TDI/PI.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#24364 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABQHIluljjVWby0HQEs-9VSqTVrke2Kwks5u7Rg3gaJpZM4ZbLQI>
.
|
Probably a typo. Lots of open windows ATM. |
that's fine, but wont' accept a change that also does not fix the existing Index codebases. This is SO confusing you need as much consistency as possible. |
I'm pretty confused right now, so I'll restate what Brock and I are saying.
Maybe you could restate what you're looking for @jreback? |
Did we ever reach a consensus here? |
thanks. I realized you are just changing the non-Index idiom here which is in-line with other idioms. |
cc @TomAugspurger
If I did this right, this shouldn't cause rebasing headaches. LMK if I messed up on that and I'll try to fix.
Nearly everything here is verbatim from #24024. I'll comment inline with pieces that are not.