Return type depends on input. Delayed if scalar, otherwise same as input. For errors, only "raise" and "coerce" are allowed.
(arg, errors="raise", downcast=None, meta=None)
| 6091 | |
| 6092 | @derived_from(pd, ua_args=["downcast"]) |
| 6093 | def to_numeric(arg, errors="raise", downcast=None, meta=None): |
| 6094 | """ |
| 6095 | Return type depends on input. Delayed if scalar, otherwise same as input. |
| 6096 | For errors, only "raise" and "coerce" are allowed. |
| 6097 | """ |
| 6098 | if errors not in ("raise", "coerce"): |
| 6099 | raise ValueError("invalid error value specified") |
| 6100 | |
| 6101 | if pd_is_scalar(arg): |
| 6102 | if meta is not None: |
| 6103 | raise KeyError("``meta`` is not allowed when input is a scalar.") |
| 6104 | return delayed(pd.to_numeric, pure=True)(arg, errors=errors, downcast=downcast) |
| 6105 | |
| 6106 | if is_arraylike(arg): |
| 6107 | return new_collection( |
| 6108 | ToNumeric( |
| 6109 | from_array(arg).astype(arg.dtype), errors=errors, downcast=downcast |
| 6110 | ) |
| 6111 | ).to_dask_array(meta=meta) |
| 6112 | |
| 6113 | if is_series_like(arg): |
| 6114 | return new_collection( |
| 6115 | ToNumeric(frame=arg, errors=errors, downcast=downcast, meta=meta) |
| 6116 | ) |
| 6117 | |
| 6118 | raise TypeError( |
| 6119 | "arg must be a list, tuple, dask.array.Array, or dask.dataframe.Series" |
| 6120 | ) |
| 6121 | |
| 6122 | |
| 6123 | @wraps(pd.to_datetime) |
searching dependent graphs…