Skip to content

arro3.compute

arro3.compute

Array

An Arrow Array.

field property

field: Field

Access the field stored on this Array.

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

type property

type: DataType

The data type of this array.

__array__

__array__(dtype=None, copy=None) -> NDArray

An implementation of the Array interface, for interoperability with numpy and other array libraries.

__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 array into a pyarrow array, without copying memory.

__init__

__init__(
    obj: ArrowArrayExportable | Sequence[Any],
    /,
    type: ArrowSchemaExportable | None = None,
) -> None

Create arro3.core.Array instance from a sequence of Python objects.

Parameters:

cast

cast(target_type: ArrowSchemaExportable) -> Array

Cast array values to another data type

Parameters:

from_arrow classmethod

Construct this object from an existing Arrow object.

It can be called on anything that exports the Arrow data interface (__arrow_c_array__).

Parameters:

Returns:

from_arrow_pycapsule classmethod

from_arrow_pycapsule(schema_capsule, array_capsule) -> Array

Construct this object from bare Arrow PyCapsules

from_numpy classmethod

from_numpy(array: ndarray) -> Array

Construct an Array from a numpy ndarray

slice

slice(offset: int = 0, length: int | None = None) -> Array

Compute zero-copy slice of this array.

Parameters:

  • offset (int, default: 0 ) –

    Defaults to 0.

  • length (int | None, default: None ) –

    Defaults to None.

Returns:

  • Array

    The sliced array

to_numpy

to_numpy() -> NDArray

Return a numpy copy of this array.

ArrayReader

A stream of Arrow Arrays.

This is similar to the RecordBatchReader but each item yielded from the stream is an Array, not a RecordBatch.

closed property

closed: bool

Returns true if this reader has already been consumed.

field property

field: Field

Access the field of this reader.

__arrow_c_stream__

__arrow_c_stream__(requested_schema: object | None = None) -> 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.chunked_array() to convert this ArrayReader to a pyarrow ChunkedArray, without copying memory.

from_arrow classmethod

Construct this from an existing Arrow object.

It can be called on anything that exports the Arrow stream interface (has an __arrow_c_stream__ method), such as a Table or ArrayReader.

from_arrow_pycapsule classmethod

from_arrow_pycapsule(capsule) -> ArrayReader

Construct this object from a bare Arrow PyCapsule

from_stream classmethod

from_stream(data: ArrowStreamExportable) -> ArrayReader

Construct this from an existing Arrow object.

This is an alias of and has the same behavior as from_arrow, but is included for parity with pyarrow.RecordBatchReader.

read_all

read_all() -> ChunkedArray

Read all batches from this stream into a ChunkedArray.

read_next_array

read_next_array() -> Array

Read the next array from this stream.

list_flatten

list_flatten(
    input: ArrowArrayExportable | ArrowStreamExportable,
) -> Array | ArrayReader

Unnest this ListArray, LargeListArray or FixedSizeListArray.

Parameters:

  • input (ArrowArrayExportable | ArrowStreamExportable) –

    description

Returns:

list_offsets

list_offsets(
    input: ArrowArrayExportable | ArrowStreamExportable, *, logical: bool = True
) -> Array | ArrayReader

Access the offsets of this ListArray or LargeListArray

Parameters:

  • input (ArrowArrayExportable | ArrowStreamExportable) –

    description

  • physical

    If False, return the physical (unsliced) offsets of the provided list array. If True, adjust the list offsets for the current array slicing. Defaults to True.

Returns:

struct_field

struct_field(
    values: ArrowArrayExportable, /, indices: int | Sequence[int]
) -> Array

Access a column within a StructArray by index

Parameters:

  • values (ArrowArrayExportable) –

    Argument to compute function.

  • indices (int | Sequence[int]) –

    List of indices for chained field lookup, for example [4, 1] will look up the second nested field in the fifth outer field.

Returns: