Skip to content

pd.to_numeric(series, downcast='integer') does not prpoerly handle floats over 10,000 #14941

Closed
@gryBox

Description

@gryBox

Hi - I came across this issue in stackoverflow while testing pd.to_numeric()

If all floats in column are over 10000 it loses precision and converts them to integers.

tst_df = pd.DataFrame({'colA':['a','b','c','a','z', 'q'],
                      'colB': pd.date_range(end=datetime.datetime.now() , periods=6),
                      'colC' : ['a1','b2','c3','a4','z5', 'q6'],
                      'colD': [10000.0, 20000, 3000, 40000.36, 50000, 50000.00]})

pd.to_numeric(tst_df['colD'],  downcast='integer')

image

This doesn't seem like the desired behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugNumeric OperationsArithmetic, Comparison, and Logical operations

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions