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
ortuples
, or mapping ofstrings
toDataTypes
Each field must have a UTF8-encoded name, and these field names arepart of the type metadata.
- fieldsiterable of
- Returns:
- type
DataType
- type
Examples
Create an instance of StructType from an iterable of tuples:
>>>importpyarrowaspa>>>fields=[...('f1',pa.int32()),...('f2',pa.string()),...]>>>struct_type=pa.struct(fields)>>>struct_typeStructType(struct<f1: int32, f2: string>)
Retrieve a field from a StructType:
>>>struct_type[0]pyarrow.Field<f1: int32>>>>struct_type['f1']pyarrow.Field<f1: int32>
Create an instance of StructType from an iterable of Fields:
>>>fields=[...pa.field('f1',pa.int32()),...pa.field('f2',pa.string(),nullable=False),...]>>>pa.struct(fields)StructType(struct<f1: int32, f2: string not null>)
On this page