pyarrow.struct

pyarrow.struct(fields)

Create StructType instance from fields.

A struct is a nested type parameterized by an ordered sequence of types (which can all be distinct), called its fields.

Parameters:
fieldsiterable of Fields or tuples, or mapping of strings to DataTypes

Each field must have a UTF8-encoded name, and these field names are part of the type metadata.

Returns:
typeDataType

Examples

>>> import pyarrow as pa
>>> fields = [
...     ('f1', pa.int32()),
...     ('f2', pa.string()),
... ]
>>> struct_type = pa.struct(fields)
>>> struct_type
StructType(struct<f1: int32, f2: string>)
>>> fields = [
...     pa.field('f1', pa.int32()),
...     pa.field('f2', pa.string(), nullable=False),
... ]
>>> pa.struct(fields)
StructType(struct<f1: int32, f2: string not null>)