def to_numeric(arg, errors='raise', downcast=None):
 if (downcast not in (None, 'integer', 'signed', 'unsigned', 'float')):
  raise ValueError('invalid downcasting method provided')
 is_series = False
 is_index = False
 is_scalar = False
 if isinstance(arg, pd.Series):
  is_series = True
  values = arg.values
 elif isinstance(arg, pd.Index):
  is_index = True
  values = arg.asi8
  if (values is None):
   values = arg.values
 elif isinstance(arg, (list, tuple)):
  values = np.array(arg, dtype='O')
 elif isscalar(arg):
  if is_decimal(arg):
   return float(arg)
  if is_number(arg):
   return arg
  is_scalar = True
  values = np.array([arg], dtype='O')
 elif (getattr(arg, 'ndim', 1) > 1):
  raise TypeError('arg must be a list, tuple, 1-d array, or Series')
 else:
  values = arg
 try:
  if is_numeric_dtype(values):
   pass
  elif is_datetime_or_timedelta_dtype(values):
   values = values.astype(np.int64)
  else:
   values = _ensure_object(values)
   coerce_numeric = (False if (errors in ('ignore', 'raise')) else True)
   values = lib.maybe_convert_numeric(values, set(), coerce_numeric=coerce_numeric)
 except Exception:
  if (errors == 'raise'):
   raise
 if ((downcast is not None) and is_numeric_dtype(values)):
  typecodes = None
  if (downcast in ('integer', 'signed')):
   typecodes = np.typecodes['Integer']
  elif ((downcast == 'unsigned') and (np.min(values) >= 0)):
   typecodes = np.typecodes['UnsignedInteger']
  elif (downcast == 'float'):
   typecodes = np.typecodes['Float']
   float_32_char = np.dtype(np.float32).char
   float_32_ind = typecodes.index(float_32_char)
   typecodes = typecodes[float_32_ind:]
  if (typecodes is not None):
   for dtype in typecodes:
    if (np.dtype(dtype).itemsize <= values.dtype.itemsize):
     values = _possibly_downcast_to_dtype(values, dtype)
     if (values.dtype == dtype):
      break
 if is_series:
  return pd.Series(values, index=arg.index, name=arg.name)
 elif is_index:
  return Index(values, name=arg.name)
 elif is_scalar:
  return values[0]
 else:
  return values

def to_numeric ( arg , errors = 'raise' , downcast = None ) : if ( downcast not in ( None , 'integer' , 'signed' , 'unsigned' , 'float' ) ) : raise ValueError ( 'invalid downcasting method provided' ) is_series = False is_index = False is_scalar = False if isinstance ( arg , pd . Series ) : is_series = True values = arg . values elif isinstance ( arg , pd . Index ) : is_index = True values = arg . asi8 if ( values is None ) : values = arg . values elif isinstance ( arg , ( list , tuple ) ) : values = np . array ( arg , dtype = 'O' ) elif isscalar ( arg ) : if is_decimal ( arg ) : return float ( arg ) if is_number ( arg ) : return arg is_scalar = True values = np . array ( [ arg ] , dtype = 'O' ) elif ( getattr ( arg , 'ndim' , 1 ) > 1 ) : raise TypeError ( 'arg must be a list, tuple, 1-d array, or Series' ) else : values = arg try : if is_numeric_dtype ( values ) : pass elif is_datetime_or_timedelta_dtype ( values ) : values = values . astype ( np . int64 ) else : values = _ensure_object ( values ) coerce_numeric = ( False if ( errors in ( 'ignore' , 'raise' ) ) else True ) values = lib . maybe_convert_numeric ( values , set ( ) , coerce_numeric = coerce_numeric ) except Exception : if ( errors == 'raise' ) : raise if ( ( downcast is not None ) and is_numeric_dtype ( values ) ) : typecodes = None if ( downcast in ( 'integer' , 'signed' ) ) : typecodes = np . typecodes [ 'Integer' ] elif ( ( downcast == 'unsigned' ) and ( np . min ( values ) >= 0 ) ) : typecodes = np . typecodes [ 'UnsignedInteger' ] elif ( downcast == 'float' ) : typecodes = np . typecodes [ 'Float' ] float_32_char = np . dtype ( np . float32 ) . char float_32_ind = typecodes . index ( float_32_char ) typecodes = typecodes [ float_32_ind : ] if ( typecodes is not None ) : for dtype in typecodes : if ( np . dtype ( dtype ) . itemsize <= values . dtype . itemsize ) : values = _possibly_downcast_to_dtype ( values , dtype ) if ( values . dtype == dtype ) : break if is_series : return pd . Series ( values , index = arg . index , name = arg . name ) elif is_index : return Index ( values , name = arg . name ) elif is_scalar : return values [ 0 ] else : return values
return value of a numeric literal string .