Skip to content
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

ENH: Better error message for trying to convert to "double," type #60685

Open
1 of 3 tasks
benrutter opened this issue Jan 9, 2025 · 0 comments
Open
1 of 3 tasks

ENH: Better error message for trying to convert to "double," type #60685

benrutter opened this issue Jan 9, 2025 · 0 comments
Labels
Enhancement Needs Triage Issue that has not been reviewed by a pandas team member

Comments

@benrutter
Copy link

benrutter commented Jan 9, 2025

Feature Type

  • Adding new functionality to pandas

  • Changing existing functionality in pandas

  • Removing existing functionality in pandas

Problem Description

I (don't ask how 😅) came over the fact that this:

pd.DataFrame({"a": [1, 2, 3]}).astype("hurdy-gurdy")

Raises a helpful 'TypeError: data type "hurdy-gurdy" not understood message'

But this doesn't happen if the incorrect type is "double," (I'm not sure why but I assume something around the fact that pandas needs to check for types such as "double[pyarrow]").

This code:

pd.DataFrame({"a": [1, 2, 3]}).astype("double,")

Raises the error: "TypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''".

Feature Description

Throw the safe "double," is not a valid type error message

Alternative Solutions

Probably involves digging slightly into the part of the code that's throwing an error - I'd love to put in a PR if this is something that'd be accepted?

Additional Context

No response

@benrutter benrutter added Enhancement Needs Triage Issue that has not been reviewed by a pandas team member labels Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Needs Triage Issue that has not been reviewed by a pandas team member
Projects
None yet
Development

No branches or pull requests

1 participant