def to_numeric(arg, errors='<STR_LIT>', downcast=None):
if downcast not in (None, '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT:float>'):<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>is_series = False<EOL>is_index = False<EOL>is_scalars = False<EOL>if isinstance(arg, ABCSeries):<EOL><INDENT>is_series = True<EOL>values = arg.values<EOL><DEDENT>elif isinstance(arg, ABCIndexClass):<EOL><INDENT>is_index = True<EOL>values = arg.asi8<EOL>if values is None:<EOL><INDENT>values = arg.values<EOL><DEDENT><DEDENT>elif isinstance(arg, (list, tuple)):<EOL><INDENT>values = np.array(arg, dtype='<STR_LIT:O>')<EOL><DEDENT>elif is_scalar(arg):<EOL><INDENT>if is_decimal(arg):<EOL><INDENT>return float(arg)<EOL><DEDENT>if is_number(arg):<EOL><INDENT>return arg<EOL><DEDENT>is_scalars = True<EOL>values = np.array([arg], dtype='<STR_LIT:O>')<EOL><DEDENT>elif getattr(arg, '<STR_LIT>', <NUM_LIT:1>) > <NUM_LIT:1>:<EOL><INDENT>raise TypeError('<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>values = arg<EOL><DEDENT>try:<EOL><INDENT>if is_numeric_dtype(values):<EOL><INDENT>pass<EOL><DEDENT>elif is_datetime_or_timedelta_dtype(values):<EOL><INDENT>values = values.astype(np.int64)<EOL><DEDENT>else:<EOL><INDENT>values = ensure_object(values)<EOL>coerce_numeric = errors not in ('<STR_LIT:ignore>', '<STR_LIT>')<EOL>values = lib.maybe_convert_numeric(values, set(),<EOL>coerce_numeric=coerce_numeric)<EOL><DEDENT><DEDENT>except Exception:<EOL><INDENT>if errors == '<STR_LIT>':<EOL><INDENT>raise<EOL><DEDENT><DEDENT>if downcast is not None and is_numeric_dtype(values):<EOL><INDENT>typecodes = None<EOL>if downcast in ('<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>typecodes = np.typecodes['<STR_LIT>']<EOL><DEDENT>elif downcast == '<STR_LIT>' and np.min(values) >= <NUM_LIT:0>:<EOL><INDENT>typecodes = np.typecodes['<STR_LIT>']<EOL><DEDENT>elif downcast == '<STR_LIT:float>':<EOL><INDENT>typecodes = np.typecodes['<STR_LIT>']<EOL>float_32_char = np.dtype(np.float32).char<EOL>float_32_ind = typecodes.index(float_32_char)<EOL>typecodes = typecodes[float_32_ind:]<EOL><DEDENT>if typecodes is not None:<EOL><INDENT>for dtype in typecodes:<EOL><INDENT>if np.dtype(dtype).itemsize <= values.dtype.itemsize:<EOL><INDENT>values = maybe_downcast_to_dtype(values, dtype)<EOL>if values.dtype == dtype:<EOL><INDENT>break<EOL><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT>if is_series:<EOL><INDENT>return pd.Series(values, index=arg.index, name=arg.name)<EOL><DEDENT>elif is_index:<EOL><INDENT>return pd.Index(values, name=arg.name)<EOL><DEDENT>elif is_scalars:<EOL><INDENT>return values[<NUM_LIT:0>]<EOL><DEDENT>else:<EOL><INDENT>return values<EOL><DEDENT>
Convert argument to a numeric type.

The default return dtype is `float64` or `int64`
depending on the data supplied. Use the `downcast` parameter
to obtain other dtypes.

Please note that precision loss may occur if really large numbers
are passed in. Due to the internal limitations of `ndarray`, if
numbers smaller than `-9223372036854775808` (np.iinfo(np.int64).min)
or larger than `18446744073709551615` (np.iinfo(np.uint64).max) are
passed in, it is very likely they will be converted to float so that
they can stored in an `ndarray`. These warnings apply similarly to
`Series` since it internally leverages `ndarray`.

Parameters
----------
arg : scalar, list, tuple, 1-d array, or Series
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 : {'integer', 'signed', 'unsigned', 'float'} , default None
    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 according to the following rules:

    - 'integer' or 'signed': smallest signed int dtype (min.: np.int8)
    - 'unsigned': smallest unsigned int dtype (min.: np.uint8)
    - 'float': smallest float dtype (min.: np.float32)

    As this behaviour is separate from the core conversion to
    numeric values, any errors raised during the downcasting
    will be surfaced regardless of the value of the 'errors' input.

    In addition, downcasting will only occur if the size
    of the resulting data's dtype is strictly larger than
    the dtype it is to be cast to, so if none of the dtypes
    checked satisfy that specification, no downcasting will be
    performed on the data.

    .. versionadded:: 0.19.0

Returns
-------
ret : numeric if parsing succeeded.
    Return type depends on input.  Series if Series, otherwise ndarray.

See Also
--------
DataFrame.astype : Cast argument to a specified dtype.
to_datetime : Convert argument to datetime.
to_timedelta : Convert argument to timedelta.
numpy.ndarray.astype : Cast a numpy array to a specified type.

Examples
--------
Take separate series and convert to numeric, coercing when told to

>>> s = pd.Series(['1.0', '2', -3])
>>> pd.to_numeric(s)
0    1.0
1    2.0
2   -3.0
dtype: float64
>>> pd.to_numeric(s, downcast='float')
0    1.0
1    2.0
2   -3.0
dtype: float32
>>> pd.to_numeric(s, downcast='signed')
0    1
1    2
2   -3
dtype: int8
>>> s = pd.Series(['apple', '1.0', '2', -3])
>>> pd.to_numeric(s, errors='ignore')
0    apple
1      1.0
2        2
3       -3
dtype: object
>>> pd.to_numeric(s, errors='coerce')
0    NaN
1    1.0
2    2.0
3   -3.0
dtype: float64