-
-
Notifications
You must be signed in to change notification settings - Fork 25.9k
FIX _safe_indexing: improve error message for string indexing on axis=0 #31494
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
base: main
Are you sure you want to change the base?
FIX _safe_indexing: improve error message for string indexing on axis=0 #31494
Conversation
❌ Linting issuesThis PR is introducing linting issues. Here's a summary of the issues. Note that you can avoid having linting issues by enabling You can see the details of the linting issues under the
|
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.
You should enable pre-commit
hooks to fix your linting issues in your commits.
raise ValueError( | ||
f"String indexing (indices={indices}) is not supported with 'axis=0'. Did you mean to use axis=1 for column selection?" | ||
) |
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.
raise ValueError( | |
f"String indexing (indices={indices}) is not supported with 'axis=0'. Did you mean to use axis=1 for column selection?" | |
) | |
raise ValueError( | |
f"String indexing (indices={indices}) is not supported with 'axis=0'. " | |
"Did you mean to use axis=1 for column selection?" | |
) |
This PR makes the ValueError from sklearn.utils._indexing._safe_indexing more informative
when a string index is passed with axis=0. The new message shows the actual value of
indices
and suggests using axis=1 for column selection.ValueError(f"String indexing (indices={indices}) is not supported with 'axis=0'. "
"Did you mean to use axis=1 for column selection?")
(using a regex).
All existing indexing tests now pass. The only local test failure is test_openmp_parallelism_enabled,
which can be ignored on macOS; CI will run on Linux with OpenMP support.