to_numeric#
- caf.toolkit.pandas_utils.utility.to_numeric(arg: ndarray, errors: Literal['ignore', 'raise', 'coerce'] = 'raise', downcast: Literal['integer', 'signed', 'unsigned', 'float'] | None = None, **kwargs) ndarray [source]#
- caf.toolkit.pandas_utils.utility.to_numeric(arg: Index, errors: Literal['ignore', 'raise', 'coerce'] = 'raise', downcast: Literal['integer', 'signed', 'unsigned', 'float'] | None = None, **kwargs) Index
- caf.toolkit.pandas_utils.utility.to_numeric(arg: Series, errors: Literal['ignore', 'raise', 'coerce'] = 'raise', downcast: Literal['integer', 'signed', 'unsigned', 'float'] | None = None, **kwargs) Series
Convert argument to numeric type.
Wraps pandas.to_numeric and adds option to ignore errors.
- Parameters:
arg (1-d array, Series or Index) – Argument to be converted.
errors ({'ignore', 'raise','coerce'}, default 'raise') –
If ‘raise’, then invalid parsing will raise an exception.
If ‘coerce’, then invalid parsing will be set as NaN.
If ‘ignore’, then invalid parsing will return the input.
downcast (str, default None) – Can be ‘integer’, ‘signed’, ‘unsigned’, or ‘float’. If not None, and if the data has been successfully cast to a numerical dtype (or if the data was numeric to begin with), downcast that resulting data to the smallest numerical dtype possible.
- Returns:
Numeric if parsing succeeded. Return type depends on input. Series if Series, Index if Index, otherwise ndarray.
- Return type:
pd.Series | pd.Index | np.ndarray
See also
pd.to_numeric