Skip to content

REF: share code for scalar validation in datetimelike array methods #34076

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 8 commits into from
May 12, 2020

Conversation

jbrockmendel
Copy link
Member

The user-facing effect here is in the exception messages we show to users, where we may want to be more verbose than this. Thoughts @gfyoung?

@gfyoung
Copy link
Member

gfyoung commented May 8, 2020

The user-facing effect here is in the exception messages we show to users, where we may want to be more verbose than this. Thoughts @gfyoung?

I agree that we would want to improve the user-friendliness of these error messages. From that perspective, I prefer the error messages that were there before.

f"'value' should be a '{self._scalar_type.__name__}', 'NaT', "
f"or array of those. Got '{type(value).__name__}' instead."
)
raise TypeError(msg)
Copy link
Member

@gfyoung gfyoung May 8, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This message for example is a nicer, user-friendly one that would be good to keep.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok @gfyoung ?

@@ -760,6 +759,26 @@ def _validate_shift_value(self, fill_value):

return self._unbox(fill_value)

def _validate_scalar(self, value, msg: str, cast_str: bool = False):
if cast_str and isinstance(value, str):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add a doc-string here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

@jreback jreback added the Error Reporting Incorrect or improved errors from pandas label May 9, 2020
@jreback jreback added this to the 1.1 milestone May 9, 2020
@jreback jreback merged commit b47362d into pandas-dev:master May 12, 2020
@jbrockmendel jbrockmendel deleted the dtlike-validators-scalar branch May 12, 2020 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Error Reporting Incorrect or improved errors from pandas
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants