Feature Type

  • [X] Adding new functionality to pandas

  • [ ] Changing existing functionality in pandas

  • [ ] Removing existing functionality in pandas

Problem Description

I have a very long and wide string dataframe (e.g. 4 million rows * 1000 columns) that need to be to_numericed.

The df contains invalid values that should be coerced as NaN. Currently the only approach is to use apply

df.apply(pd.to_numeric, errors="coerce")

which takes a substantial amount time given the number of columns.

Feature Description

Allow pd.to_numeric to take dataframe directly.

Alternative Solutions

Alternatively, if astype can take coerce, if can also solve the issue.

Additional Context

No response

Comment From: joooeey

I've reported this in #48781 .

Comment From: phofl

There is no real advantage of having to_numeric taking a DataFrame, we would still have to iterate over all columns, e.g. same outcome. Closing as there is another issue about astype already