| [ Web Proxy ] |
| Viewing: https://arrow.apache.org/docs/python/generated/../../cpp/../python/generated/pyarrow.struct.html | [Back] [Original] |
Section Navigation
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.
Fields or tuples, or mapping of strings to DataTypesEach field must have a UTF8-encoded name, and these field names are part of the type metadata.
DataTypeExamples
Create an instance of StructType from an iterable of tuples:
>>> import pyarrow as pa
>>> fields = [
... ('f1', pa.int32()),
... ('f2', pa.string()),
... ]
>>> struct_type = pa.struct(fields)
>>> struct_type
StructType(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>)
Copyright 2016-2026 Apache Software Foundation.
Apache Arrow, Arrow, Apache, the Apache logo, and the Apache Arrow project logo are either registered trademarks or trademarks of The Apache Software Foundation in the United States and other countries.
Created using Sphinx 9.1.0.
Built with the PyData Sphinx Theme 0.20.0.
| Web Proxy Viewer | New URL | Original Page |