Skip to content

Scalar

arro3.core.Scalar

An arrow Scalar.

field property

field: Field

Access the field stored on this Scalar.

Note that this field usually will not have a name associated, but it may have metadata that signifies that this scalar is an extension (user-defined typed) scalar.

is_valid property

is_valid: bool

Return True if this scalar is not null.

type property

type: DataType

Access the type of this scalar.

__arrow_c_array__

__arrow_c_array__(
    requested_schema: object | None = None,
) -> tuple[object, object]

An implementation of the Arrow PyCapsule Interface. This dunder method should not be called directly, but enables zero-copy data transfer to other Python libraries that understand Arrow memory.

For example, you can call pyarrow.array() to convert this Scalar into a pyarrow Array, without copying memory. The generated array is guaranteed to have length 1.

__eq__

__eq__(other) -> bool

Check for equality with other Python objects (==)

If other is not an Arrow scalar, self will be converted to a Python object (with as_py), and then its __eq__ method will be called.

__init__

__init__(obj: ArrayInput, /, type: None = None) -> None
__init__(obj: Any, /, type: ArrowSchemaExportable) -> None
__init__(
    obj: ArrayInput | Any, /, type: ArrowSchemaExportable | None = None
) -> None

Create arro3.Scalar instance from a Python object.

Parameters:

  • obj (ArrayInput | Any) –

    An input object.

  • type (ArrowSchemaExportable | None, default: None ) –

    Explicit type to attempt to coerce to. You may pass in a Field to type in order to associate extension metadata with this array.

as_py

as_py() -> Any

Convert this scalar to a pure-Python object.

cast

cast(target_type: ArrowSchemaExportable) -> Scalar

Cast scalar to another data type

Parameters:

from_arrow classmethod

from_arrow(input: ArrowArrayExportable) -> Scalar

Construct this from an existing Arrow Scalar.

It can be called on anything that exports the Arrow data interface (has a __arrow_c_array__ method) and returns an array with a single element.

Parameters:

Returns:

from_arrow_pycapsule classmethod

from_arrow_pycapsule(schema_capsule, array_capsule) -> Scalar

Construct this object from bare Arrow PyCapsules