def toNumber(a):
  """
  Convert any input a to a number type
  if can not convert, then return nan
  """
  if isinstance(a, (int, float)):
    return a
  try:
    return int(a)
  except (ValueError, TypeError):
    try:
      return float(a)
    except (ValueError, TypeError):
      return float('nan')