pyarrow.scalar#

pyarrow.scalar(value,type=None,*,from_pandas=None,MemoryPoolmemory_pool=None)#

Create a pyarrow.Scalar instance from a Python object.

Parameters:
valueAny

Python object coercible to arrow’s type system.

typepyarrow.DataType

Explicit type to attempt to coerce to, otherwise will be inferred fromthe value.

from_pandasbool, defaultNone

Use pandas’s semantics for inferring nulls from values inndarray-like data. Defaults to False if not passed explicitly by user,or True if a pandas object is passed in.

memory_poolpyarrow.MemoryPool, optional

If not passed, will allocate memory from the currently-set defaultmemory pool.

Returns:
scalarpyarrow.Scalar

Examples

>>>importpyarrowaspa
>>>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]>