-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
fix Error Indexing DafaFrame with a 0-d array #22032
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2692,8 +2692,9 @@ def is_nested_tuple(tup, labels): | |
|
||
def is_list_like_indexer(key): | ||
# allow a list_like, but exclude NamedTuples which can be indexers | ||
return is_list_like(key) and not (isinstance(key, tuple) and | ||
type(key) is not tuple) | ||
return (is_list_like(key) | ||
and not (isinstance(key, tuple) and type(key) is not tuple) | ||
and not np.array(key).ndim == 0) | ||
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. You're really just checking if you have a scalar. Is it possible to use (and potentially modify) 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. Possibly! I'll look into that more tomorrow. |
||
|
||
|
||
def is_label_like(key): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -890,6 +890,13 @@ def test_no_reference_cycle(self): | |
del df | ||
assert wr() is None | ||
|
||
def test_zero_index_iloc_raises(self): | ||
df = pd.DataFrame([[1, 2], [3, 4]], columns=['a', 'b']) | ||
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. Reference issue as a comment below the function 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. Can do. |
||
ar = np.array(0) | ||
msg = 'Cannot index by location index with a non-integer key' | ||
with assert_raises_regex(TypeError, msg): | ||
df.iloc[ar] | ||
|
||
|
||
class TestSeriesNoneCoercion(object): | ||
EXPECTED_RESULTS = [ | ||
|
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.
pls don’t do this
you end up materializing the key which could be expensive
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.
Yea I wasn't really happy with it as is anyways and since it seems to break some tests I'll probably change it in the AM.