pyarrow.compute.struct_field

pyarrow.compute.struct_field(values, /, indices, *, options=None, memory_pool=None)

Extract children of a struct or union by index.

Given a list of indices (passed via StructFieldOptions), extract the child array or scalar with the given child index, recursively.

For union inputs, nulls are emitted for union values that reference a different child than specified. Also, the indices are always in physical order, not logical type codes - for example, the first child is always index 0.

An empty list of indices returns the argument unchanged.

Parameters
valuesArray-like or scalar-like

Argument to compute function.

indicessequence of int

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

optionspyarrow.compute.StructFieldOptions, optional

Alternative way of passing options.

memory_poolpyarrow.MemoryPool, optional

If not passed, will allocate memory from the default memory pool.