-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
ENH: Improve error mesage verbosity in string accessor #59900
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
Conversation
@rhshadrach - could you take a look at this? thanks |
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.
Looking good - if this isn't currently hit by tests, they should be added.
pandas/core/strings/accessor.py
Outdated
@@ -255,7 +255,9 @@ def _validate(data): | |||
inferred_dtype = lib.infer_dtype(values, skipna=True) | |||
|
|||
if inferred_dtype not in allowed_types: | |||
raise AttributeError("Can only use .str accessor with string values!") | |||
raise AttributeError( | |||
f"Can only use .str accessor with string values!, not {inferred_dtype}" |
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.
Can you remove the !
, I believe it is not grammatically correct.
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.
Looks good! Can you update the test test_str_attribute
in tests/series/accessors/test_str_accessor.py
. Right now it is checking this case, but only checks part of the message. I think we can just update that to test the full message for this.
I think this looks good, but the CI has many unrelated failures. I'd like to get those resolved before merging PRs. |
CI is fixed, can you merge main. |
@rhshadrach - CI looks good. Thanks |
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.
lgtm
Thanks @KevsterAmp |
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.Continued stale PR: #59649