-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
BUG: raise on RangeIndex.array #40022
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 23 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
3b265b0
BUG: raise on RangeIndex.array
jbrockmendel 72ada03
Merge branch 'master' into util-extract_array
jbrockmendel be2d7fd
Merge branch 'master' into util-extract_array
jbrockmendel bd50f18
make RangeIndex check part of extract_array
jbrockmendel 947231d
Merge branch 'master' into util-extract_array
jbrockmendel 7037a46
Merge branch 'master' into util-extract_array
jbrockmendel 92ccdfe
merge master
jbrockmendel 9cc1225
Merge branch 'master' into util-extract_array
jbrockmendel 31dc8fc
Merge branch 'master' into util-extract_array
jbrockmendel 3dfbc08
Merge branch 'master' into util-extract_array
jbrockmendel 6bf4a8f
restore RangeIndex.array
jbrockmendel c4882ac
Merge branch 'master' into util-extract_array
jbrockmendel bc7c628
troubleshoot ci
jbrockmendel c5977d6
Update pandas/core/construction.py
jbrockmendel ce578f6
Merge branch 'master' into util-extract_array
jbrockmendel 217dd68
no longer need to skip array manager test
jbrockmendel 5c24b75
flake8 fixup
jbrockmendel ae87afa
Merge branch 'master' into util-extract_array
jbrockmendel 20bb6fc
mypy fixup
jbrockmendel 9dcf5f4
revert xfail
jbrockmendel 13c7c70
Merge branch 'master' into util-extract_array
jbrockmendel 2caa121
Merge branch 'master' into util-extract_array
jbrockmendel 7e05c61
Merge branch 'master' into util-extract_array
jbrockmendel 190efa6
Merge branch 'master' into util-extract_array
jbrockmendel 0eace12
Merge branch 'master' into util-extract_array
jbrockmendel b7d1e3d
Merge branch 'master' into util-extract_array
jbrockmendel e88503e
Merge branch 'master' into util-extract_array
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
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 |
---|---|---|
|
@@ -30,7 +30,10 @@ | |
ensure_platform_int, | ||
is_extension_array_dtype, | ||
) | ||
from pandas.core.dtypes.generic import ABCMultiIndex | ||
from pandas.core.dtypes.generic import ( | ||
ABCMultiIndex, | ||
ABCRangeIndex, | ||
) | ||
from pandas.core.dtypes.missing import isna | ||
|
||
from pandas.core.construction import extract_array | ||
|
@@ -367,9 +370,12 @@ def nargsort( | |
mask=mask, | ||
) | ||
|
||
items = extract_array(items) | ||
if isinstance(items, ABCRangeIndex): | ||
return items.argsort(ascending=ascending) # TODO: test coverage with key? | ||
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. hmm if you use extract_range on L376 i think you can just fall thru no? (or I guess need L380 to change), anyhow for the future |
||
elif not isinstance(items, ABCMultiIndex): | ||
items = extract_array(items) | ||
if mask is None: | ||
mask = np.asarray(isna(items)) | ||
mask = np.asarray(isna(items)) # TODO: does this exclude MultiIndex too? | ||
|
||
if is_extension_array_dtype(items): | ||
return items.argsort(ascending=ascending, kind=kind, na_position=na_position) | ||
|
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
Empty file.
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from pandas import Index | ||
import pandas._testing as tm | ||
from pandas.core.construction import extract_array | ||
|
||
|
||
def test_extract_array_rangeindex(): | ||
ri = Index(range(5)) | ||
|
||
expected = ri._values | ||
res = extract_array(ri, extract_numpy=True, extract_range=True) | ||
tm.assert_numpy_array_equal(res, expected) | ||
res = extract_array(ri, extract_numpy=False, extract_range=True) | ||
tm.assert_numpy_array_equal(res, expected) | ||
|
||
res = extract_array(ri, extract_numpy=True, extract_range=False) | ||
tm.assert_index_equal(res, ri) | ||
res = extract_array(ri, extract_numpy=False, extract_range=False) | ||
tm.assert_index_equal(res, ri) |
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.