Skip to content

DOC: Lacking information on error type raised by pd.to_numeric #61811

Open
@ericludvigs

Description

@ericludvigs

Pandas version checks

  • I have checked that the issue still exists on the latest versions of the docs on main here

Location of the documentation

https://pandas.pydata.org/docs/reference/api/pandas.to_numeric.html

Documentation problem

There is no "Raises" section that describes which errors are raised when setting the argument "errors" to "raise". It is not immediately clear if a conversion error will cause a TypeError or ValueError, or both depending on how conversion failed.

This would be useful when doing as recommended to "Catch exceptions explicitly instead.", and writing a try: except: with specific errors caught to avoid an overly generic error-catch which is bad practice etc. etc.

Suggested fix for documentation

Add a "Raises:" section or include specific error names instead of the generic "Raises an exception".

See for example: https://numpy.org/doc/2.1/reference/generated/numpy.array.html

For False it raises a ValueError if a copy cannot be avoided. Default: True.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DocsNeeds TriageIssue that has not been reviewed by a pandas team member

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions