Skip to main content
`Ctrl`+`K`

# pandas.api.types.is_scalar

pandas.api.types.is_scalar(val)

  Return True if given object is scalar.

  This function determines whether a given Python object is a scalar value rather than a collection. Scalars include numeric types, strings, bytes, dates, timedeltas, intervals, periods, and `None`.

  Parameters:
    val object

      This includes:

      - numpy array scalar (e.g. np.int64)

      - Python builtin numerics

      - Python builtin byte arrays and strings

      - None

      - datetime.datetime

      - datetime.timedelta

      - Period

      - decimal.Decimal

      - Interval

      - DateOffset

      - Fraction

      - Number.

  Returns:
    bool

      Return True if given object is scalar.

  See also

  `api.types.is_list_like`

    Check if the input is list-like.

  `api.types.is_integer`

    Check if the input is an integer.

  `api.types.is_float`

    Check if the input is a float.

  `api.types.is_bool`

    Check if the input is a boolean.

  Examples

      >>> import datetime
      >>> dt = datetime.datetime(2018, 10, 3)
      >>> pd.api.types.is_scalar(dt)
      True

      >>> pd.api.types.is_scalar([2, 3])
      False

      >>> pd.api.types.is_scalar({0: 1, 2: 3})
      False

      >>> pd.api.types.is_scalar((0, 2))
      False

  pandas supports PEP 3141 numbers:

      >>> from fractions import Fraction
      >>> pd.api.types.is_scalar(Fraction(3, 5))
      True