Skip to content

[BUG] add consistency to_numeric on empty list #32512

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 16 commits into from
Mar 16, 2020

Conversation

mikekutzma
Copy link
Contributor

@mikekutzma mikekutzma commented Mar 7, 2020

to_numeric should work similarly on empty lists for
downcast=unsigned/float/integer

Addresses: GH32493

to_numeric should work similarly on empty lists for
downcast=unsigned/float/integer

Addresses: GH32493
@@ -627,3 +627,12 @@ def test_non_coerce_uint64_conflict(errors, exp):
else:
result = to_numeric(ser, errors=errors)
tm.assert_series_equal(result, ser)


def test_downcast_empty():
Copy link
Member

Choose a reason for hiding this comment

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

Could you use pytest.mark.parametrize here?

Copy link
Member

@ShaharNaveh ShaharNaveh left a comment

Choose a reason for hiding this comment

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

Nitpick.

@pytest.mark.parametrize("dc1", ["integer", "float", "unsigned"])
@pytest.mark.parametrize("dc2", ["integer", "float", "unsigned"])
def test_downcast_empty(dc1, dc2):

Copy link
Member

Choose a reason for hiding this comment

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

Can you add a comment that points to the original issue?

something like:

# https://github.com/pandas-dev/pandas/issues/32493

Should do it

@jreback jreback added Dtype Conversions Unexpected or buggy dtype conversions Numeric Operations Arithmetic, Comparison, and Logical operations labels Mar 11, 2020
@jreback jreback added this to the 1.1 milestone Mar 11, 2020
Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

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

lgtm. can you add a whatsnew note in 1.1, bug fixes, numeric section. ping on green.

@mikekutzma mikekutzma requested a review from jreback March 11, 2020 23:10
Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

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

small change, pls merge master and ping on green.

@@ -162,7 +162,7 @@ def to_numeric(arg, errors="raise", downcast=None):

if downcast in ("integer", "signed"):
typecodes = np.typecodes["Integer"]
elif downcast == "unsigned" and np.min(values) >= 0:
elif downcast == "unsigned" and (len(values) == 0 or np.min(values) >= 0):
Copy link
Contributor

Choose a reason for hiding this comment

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

use not len(values)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

small change, pls merge master and ping on green.

@jreback Done 👍

@mikekutzma mikekutzma requested a review from jreback March 15, 2020 01:26
@jreback jreback merged commit 23abcd9 into pandas-dev:master Mar 16, 2020
@jreback
Copy link
Contributor

jreback commented Mar 16, 2020

thanks @mikekutzma

@mikekutzma mikekutzma deleted the bugfix/32493 branch March 20, 2020 02:04
SeeminSyed pushed a commit to CSCD01-team01/pandas that referenced this pull request Mar 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Dtype Conversions Unexpected or buggy dtype conversions Numeric Operations Arithmetic, Comparison, and Logical operations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

to_numeric fails with empty data and downcast="unsigned"
5 participants