Skip to content

DOC: downcast argument for pd.to_numeric should be integer, not int #35760

Closed
@languitar

Description

@languitar

Location of the documentation

https://pandas.pydata.org/docs/dev/reference/api/pandas.to_numeric.html?highlight=to_numeric#pandas.to_numeric

Documentation problem

The documentation declares that the downcast argument of pd.to_numeric can use the value int. However, only integer is working in the real code:

In [8]: pd.to_numeric(["42"], downcast="int", errors="coerce")
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-8-3b178e77dcd5> in <module>
----> 1 pd.to_numeric(["42"], downcast="int", errors="coerce")

/usr/lib/python3.8/site-packages/pandas/core/tools/numeric.py in to_numeric(arg, errors, downcast)
    110     """
    111     if downcast not in (None, "integer", "signed", "unsigned", "float"):
--> 112         raise ValueError("invalid downcasting method provided")
    113 
    114     if errors not in ("ignore", "raise", "coerce"):

ValueError: invalid downcasting method provided

In [9]: pd.to_numeric(["42"], downcast="integer", errors="coerce")
Out[9]: array([42], dtype=int8)

Suggested fix for documentation

Replace int with integer

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions