pyarrow.scalar

pyarrow.scalar(value, type=None, *, from_pandas=None, MemoryPool memory_pool=None)

Create a pyarrow.Scalar instance from a Python object.

Parameters
  • value (Any) – Python object coercible to arrow’s type system.

  • type (pyarrow.DataType) – Explicit type to attempt to coerce to, otherwise will be inferred from the value.

  • from_pandas (bool, default None) – Use pandas’s semantics for inferring nulls from values in ndarray-like data. Defaults to False if not passed explicitly by user, or True if a pandas object is passed in.

  • memory_pool (pyarrow.MemoryPool, optional) – If not passed, will allocate memory from the currently-set default memory pool.

Returns

scalar (pyarrow.Scalar)

Examples

>>> import pyarrow as pa
>>> pa.scalar(42)
<pyarrow.Int64Scalar: 42>
>>> pa.scalar("string")
<pyarrow.StringScalar: 'string'>
>>> pa.scalar([1, 2])
<pyarrow.ListScalar: [1, 2]>
>>> pa.scalar([1, 2], type=pa.list_(pa.int16()))
<pyarrow.ListScalar: [1, 2]>