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

BUG: Don't raise TypeError when converting NA from string to numeric #37268

Merged
merged 4 commits into from
Oct 20, 2020
Merged

BUG: Don't raise TypeError when converting NA from string to numeric #37268

merged 4 commits into from
Oct 20, 2020

Conversation

dsaxton
Copy link
Member

@dsaxton dsaxton commented Oct 20, 2020

@dsaxton dsaxton added Bug Strings String extension data type and string data NA - MaskedArrays Related to pd.NA and nullable extension arrays labels Oct 20, 2020
@jorisvandenbossche
Copy link
Member

Thanks @dsaxton. It's probably fine to fix it like this in the short term, since a proper fix to actually refactor the maybe_convert_numeric to produce nullable results is a bigger change?

@dsaxton
Copy link
Member Author

dsaxton commented Oct 20, 2020

Thanks @dsaxton. It's probably fine to fix it like this in the short term, since a proper fix to actually refactor the maybe_convert_numeric to produce nullable results is a bigger change?

That was my thinking, remove the error now then "enhance" to cast to nullable as a follow-up. I can open a separate issue for that if that makes sense?

"values, expected",
[
(["1", "2", None], Series([1, 2, np.nan])),
(["1", "2", "3"], Series([1, 2, 3])),
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 an example that has mixed values (e.g. '3' and 2 and 2.0 as well)

@jreback jreback added this to the 1.2 milestone Oct 20, 2020
@jreback jreback merged commit 71bd42b into pandas-dev:master Oct 20, 2020
@jreback
Copy link
Contributor

jreback commented Oct 20, 2020

thanks @dsaxton very nice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug NA - MaskedArrays Related to pd.NA and nullable extension arrays Strings String extension data type and string data
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: to_numeric() raises TypeError for StringDtype series
3 participants