-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Make DTI[tz]._values and Series[tz]._values return DTA #24534
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
fe01806
make _values return DatetimeArray for dt64tz
jbrockmendel 3cfb0ca
update _values test to except DTA for dt64tz
jbrockmendel a26890a
Merge branch 'master' of https://github.com/pandas-dev/pandas into va…
jbrockmendel 9bcaf77
change DTI[tz]._values and Series[dt64tz]._values to return DTA
jbrockmendel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -316,6 +316,12 @@ def _simple_new(cls, values, name=None, freq=None, tz=None, dtype=None): | |
we require the we have a dtype compat for the values | ||
if we are passed a non-dtype compat, then coerce using the constructor | ||
""" | ||
if isinstance(values, DatetimeArray): | ||
values = DatetimeArray(values, freq=freq, tz=tz, dtype=dtype) | ||
tz = values.tz | ||
freq = values.freq | ||
values = values._data | ||
|
||
# DatetimeArray._simple_new will accept either i8 or M8[ns] dtypes | ||
assert isinstance(values, np.ndarray), type(values) | ||
|
||
|
@@ -340,7 +346,7 @@ def _values(self): | |
# tz-naive -> ndarray | ||
# tz-aware -> DatetimeIndex | ||
if self.tz is not None: | ||
return self | ||
return self._eadata | ||
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. This change is obsolete in #24024 since we always return a DatetimeArray. |
||
else: | ||
return self.values | ||
|
||
|
@@ -629,6 +635,9 @@ def intersection(self, other): | |
not other.freq.isAnchored() or | ||
(not self.is_monotonic or not other.is_monotonic)): | ||
result = Index.intersection(self, other) | ||
# Invalidate the freq of `result`, which may not be correct at | ||
# this point, depending on the values. | ||
result.freq = None | ||
result = self._shallow_copy(result._values, name=result.name, | ||
tz=result.tz, freq=None) | ||
if result.freq is None: | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -477,7 +477,10 @@ def _values(self): | |
""" | ||
Return the internal repr of this data. | ||
""" | ||
return self._data.internal_values() | ||
result = self._data.internal_values() | ||
if isinstance(result, DatetimeIndex): | ||
result = result._eadata | ||
return result | ||
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. this should also be removeable in 24024 |
||
|
||
def _formatting_values(self): | ||
""" | ||
|
@@ -1602,10 +1605,6 @@ def unique(self): | |
Categories (3, object): [a < b < c] | ||
""" | ||
result = super(Series, self).unique() | ||
if isinstance(result, DatetimeIndex): | ||
# TODO: This should be unnecessary after Series._values returns | ||
# DatetimeArray | ||
result = result._eadata | ||
return result | ||
|
||
def drop_duplicates(self, keep='first', inplace=False): | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Do we have anywhere that passes a DatetimeArray here and additional keyword arguments?
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'm pretty sure we do. I'll double-check and post
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.
Yes. At the very least two tests in test_multilevel