-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Implement _most_ of the EA interface for DTA/TDA #23643
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
11 commits
Select commit
Hold shift + click to select a range
52e4d6b
implement most of the rest of EA interface
jbrockmendel c2bcd80
Merge branch 'master' of https://github.com/pandas-dev/pandas into dl…
jbrockmendel 0ce0a7c
Merge branch 'master' of https://github.com/pandas-dev/pandas into dl…
jbrockmendel 45c8161
implement some tests for take, concat_same_type
jbrockmendel 75f6944
Fixup typo, implement more tests
jbrockmendel 0fb5029
whitespace fixup
jbrockmendel 1a781ab
suggested edits
jbrockmendel ccbffe4
Merge remote-tracking branch 'upstream/master' into jbrockmendel-dlik…
TomAugspurger eceebc7
REF: Simplify concat
TomAugspurger a6065cc
copy
TomAugspurger 3cb072e
deduplicate copy
TomAugspurger 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
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
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 |
---|---|---|
|
@@ -18,7 +18,6 @@ | |
is_datetime_or_timedelta_dtype, is_dtype_equal, is_float, is_float_dtype, | ||
is_integer, is_integer_dtype, is_list_like, is_object_dtype, | ||
is_period_dtype, is_scalar, is_string_dtype) | ||
import pandas.core.dtypes.concat as _concat | ||
from pandas.core.dtypes.generic import ABCIndex, ABCIndexClass, ABCSeries | ||
from pandas.core.dtypes.missing import isna | ||
|
||
|
@@ -215,6 +214,11 @@ def ceil(self, freq, ambiguous='raise', nonexistent='raise'): | |
class DatetimeIndexOpsMixin(DatetimeLikeArrayMixin): | ||
""" common ops mixin to support a unified interface datetimelike Index """ | ||
|
||
# override DatetimeLikeArrayMixin method | ||
copy = Index.copy | ||
unique = Index.unique | ||
take = Index.take | ||
|
||
# DatetimeLikeArrayMixin assumes subclasses are mutable, so these are | ||
# properties there. They can be made into cache_readonly for Index | ||
# subclasses bc they are immutable | ||
|
@@ -685,17 +689,21 @@ def _concat_same_dtype(self, to_concat, name): | |
""" | ||
attribs = self._get_attributes_dict() | ||
attribs['name'] = name | ||
# do not pass tz to set because tzlocal cannot be hashed | ||
if len({str(x.dtype) for x in to_concat}) != 1: | ||
raise ValueError('to_concat must have the same tz') | ||
|
||
if not is_period_dtype(self): | ||
# reset freq | ||
attribs['freq'] = None | ||
|
||
if getattr(self, 'tz', None) is not None: | ||
return _concat._concat_datetimetz(to_concat, name) | ||
# TODO(DatetimeArray) | ||
# - remove the .asi8 here | ||
# - remove the _maybe_box_as_values | ||
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. looks like you can remove part of the comment |
||
# - combine with the `else` block | ||
new_data = self._concat_same_type(to_concat).asi8 | ||
else: | ||
new_data = np.concatenate([c.asi8 for c in to_concat]) | ||
new_data = type(self._values)._concat_same_type(to_concat) | ||
|
||
new_data = self._maybe_box_as_values(new_data, **attribs) | ||
return self._simple_new(new_data, **attribs) | ||
|
||
def _maybe_box_as_values(self, values, **attribs): | ||
|
@@ -704,7 +712,6 @@ def _maybe_box_as_values(self, values, **attribs): | |
# but others are not. When everyone is an ExtensionArray, this can | ||
# be removed. Currently used in | ||
# - sort_values | ||
# - _concat_same_dtype | ||
return values | ||
|
||
def astype(self, dtype, copy=True): | ||
|
@@ -761,7 +768,7 @@ def _ensure_datetimelike_to_i8(other, to_utc=False): | |
try: | ||
return np.array(other, copy=False).view('i8') | ||
except TypeError: | ||
# period array cannot be coerces to int | ||
# period array cannot be coerced to int | ||
other = Index(other) | ||
return other.asi8 | ||
|
||
|
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.