-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
REF: implement ExtensionIndex._concat_same_dtype, use for IntervalIndex #31635
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
23 commits
Select commit
Hold shift + click to select a range
b08bc6d
Use IntervalArray for IntervalIndex._concat_same_dtype
jbrockmendel 49ba586
get IntervalIndex.__getitem__ from ExtensionIndex
jbrockmendel 251d321
Merge branch 'master' of https://github.com/pandas-dev/pandas into re…
jbrockmendel 086c349
Merge branch 'master' of https://github.com/pandas-dev/pandas into re…
jbrockmendel f06d25a
Merge branch 'master' of https://github.com/pandas-dev/pandas into re…
jbrockmendel 67dc67a
implement ExtensionIndex._concat_same_dtype
jbrockmendel 84ee9fa
Merge branch 'master' of https://github.com/pandas-dev/pandas into re…
jbrockmendel 29c55a4
Merge branch 'master' of https://github.com/pandas-dev/pandas into re…
jbrockmendel e36ddcb
Merge branch 'master' of https://github.com/pandas-dev/pandas into re…
jbrockmendel aeeecd0
Merge branch 'master' of https://github.com/pandas-dev/pandas into re…
jbrockmendel 4f076fa
Merge branch 'master' of https://github.com/pandas-dev/pandas into re…
jbrockmendel 7882360
Merge branch 'master' of https://github.com/pandas-dev/pandas into re…
jbrockmendel 3e09ce7
Merge branch 'master' of https://github.com/pandas-dev/pandas into re…
jbrockmendel caa334f
Merge branch 'master' of https://github.com/pandas-dev/pandas into re…
jbrockmendel 785b957
remove defunct docstring
jbrockmendel ab3200f
flake8 fixup
jbrockmendel 20e9006
Merge branch 'master' of https://github.com/pandas-dev/pandas into re…
jbrockmendel 18d7829
typing fixup
jbrockmendel 92a17df
Merge branch 'master' of https://github.com/pandas-dev/pandas into re…
jbrockmendel 50d1cec
remove extra methods
jbrockmendel 4b42448
comments
jbrockmendel 677a40c
Merge branch 'master' of https://github.com/pandas-dev/pandas into re…
jbrockmendel 792c59d
Merge branch 'master' of https://github.com/pandas-dev/pandas into re…
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
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 |
---|---|---|
|
@@ -183,23 +183,10 @@ def func(intvidx_self, other, sort=False): | |
) | ||
@inherit_names(["set_closed", "to_tuples"], IntervalArray, wrap=True) | ||
@inherit_names( | ||
[ | ||
"__len__", | ||
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. why don't we need the deleted ones? 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. ahh i c, by reading comments. |
||
"__array__", | ||
"overlaps", | ||
"contains", | ||
"size", | ||
"dtype", | ||
"left", | ||
"right", | ||
"length", | ||
], | ||
IntervalArray, | ||
["__array__", "overlaps", "contains", "left", "right", "length"], IntervalArray, | ||
) | ||
@inherit_names( | ||
["is_non_overlapping_monotonic", "mid", "_ndarray_values", "closed"], | ||
IntervalArray, | ||
cache=True, | ||
["is_non_overlapping_monotonic", "mid", "closed"], IntervalArray, cache=True, | ||
) | ||
class IntervalIndex(IntervalMixin, ExtensionIndex): | ||
_typ = "intervalindex" | ||
|
@@ -943,33 +930,13 @@ def insert(self, loc, item): | |
new_right = self.right.insert(loc, right_insert) | ||
return self._shallow_copy(new_left, new_right) | ||
|
||
def _concat_same_dtype(self, to_concat, name): | ||
""" | ||
assert that we all have the same .closed | ||
we allow a 0-len index here as well | ||
""" | ||
if not len({i.closed for i in to_concat if len(i)}) == 1: | ||
raise ValueError( | ||
"can only append two IntervalIndex objects " | ||
"that are closed on the same side" | ||
) | ||
return super()._concat_same_dtype(to_concat, name) | ||
|
||
@Appender(_index_shared_docs["take"] % _index_doc_kwargs) | ||
def take(self, indices, axis=0, allow_fill=True, fill_value=None, **kwargs): | ||
result = self._data.take( | ||
indices, axis=axis, allow_fill=allow_fill, fill_value=fill_value, **kwargs | ||
) | ||
return self._shallow_copy(result) | ||
|
||
def __getitem__(self, value): | ||
result = self._data[value] | ||
if isinstance(result, IntervalArray): | ||
return self._shallow_copy(result) | ||
else: | ||
# scalar | ||
return result | ||
|
||
# -------------------------------------------------------------------- | ||
# Rendering Methods | ||
# __repr__ associated methods are based on MultiIndex | ||
|
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.
if you can type at some point (doc-string inherited)?