Skip to content

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
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
Contributor

@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
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 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.

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