-
-
Notifications
You must be signed in to change notification settings - Fork 18.7k
API: better error-handling for df.set_index #22486
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 1 commit
28ec3a9
8dd1453
18d3464
fa68660
6d3dfa1
159ecf5
46f8dc7
3a6469d
c3cdde2
dd8d000
47c4e74
06ed33a
9871be2
9da6e6c
361a905
42d5f2a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -234,13 +234,13 @@ def test_set_index_raise(self, frame_of_index_cols, drop, append): | |
with tm.assert_raises_regex(KeyError, 'X'): | ||
df.set_index([df['A'], df['B'], 'X'], drop=drop, append=append) | ||
|
||
rgx = 'The parameter "keys" may only contain a combination of.*' | ||
msg = 'The parameter "keys" may only contain a combination of.*' | ||
# forbidden type, e.g. set | ||
with tm.assert_raises_regex(TypeError, rgx): | ||
with tm.assert_raises_regex(TypeError, msg): | ||
df.set_index(set(df['A']), drop=drop, append=append) | ||
|
||
# forbidden type in list, e.g. set | ||
with tm.assert_raises_regex(TypeError, rgx): | ||
with tm.assert_raises_regex(TypeError, msg): | ||
df.set_index(['A', df['A'], set(df['A'])], | ||
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. see my comment above, I am not sure a set is specifically excluded. 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. I am proposing to exclude sets (see above). Irrespective of that, I need to test raising the TypeError for forbidden types (which type exactly is less relevant) |
||
drop=drop, append=append) | ||
|
||
|
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.
why are you singling out an iterable (set) is there some reason?
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.
No, just any of the types that are not allowed (I've tried to indicate as much by using "e.g.")