Bases: DataType
Concrete class for struct data types.
StructType
supports direct indexing using [...]
(implemented via __getitem__
) to access its fields. It will return the struct field with the given index or name.
Examples
Accessing fields using direct indexing:
>>> struct_type = pa.struct({'x': pa.int32(), 'y': pa.string()}) >>> struct_type[0] pyarrow.Field<x: int32> >>> struct_type['y'] pyarrow.Field<y: string>
Accessing fields using field()
:
>>> struct_type.field(1) pyarrow.Field<y: string> >>> struct_type.field('x') pyarrow.Field<x: int32>
# Creating a schema from the struct typeâs fields: >>> pa.schema(list(struct_type)) x: int32 y: string
Methods
Attributes
Bit width for fixed width type.
Examples
>>> import pyarrow as pa >>> pa.int64() DataType(int64) >>> pa.int64().bit_width 64
Byte width for fixed width type.
Examples
>>> import pyarrow as pa >>> pa.int64() DataType(int64) >>> pa.int64().byte_width 8
Return true if type is equivalent to passed value.
DataType
or str
convertible
to DataType
Whether nested Field metadata equality should be checked as well.
Examples
>>> import pyarrow as pa >>> pa.int64().equals(pa.string()) False >>> pa.int64().equals(pa.int64()) True
Select a field by its column name or numeric index.
int
or str
pyarrow.Field
Examples
>>> import pyarrow as pa >>> struct_type = pa.struct({'x': pa.int32(), 'y': pa.string()})
Select the second field:
>>> struct_type.field(1) pyarrow.Field<y: string>
Select the field named âxâ:
>>> struct_type.field('x') pyarrow.Field<x: int32>
Lists all fields within the StructType.
Examples
>>> import pyarrow as pa >>> struct_type = pa.struct([('a', pa.int64()), ('b', pa.float64()), ('c', pa.string())]) >>> struct_type.fields [pyarrow.Field<a: int64>, pyarrow.Field<b: double>, pyarrow.Field<c: string>]
Return sorted list of indices for the fields with the given name.
str
The name of the field to look up.
List
[int
]
Examples
>>> import pyarrow as pa >>> struct_type = pa.struct({'x': pa.int32(), 'y': pa.string()}) >>> struct_type.get_all_field_indices('x') [0]
Return index of the unique field with the given name.
str
The name of the field to look up.
int
The index of the field with the given name; -1 if the name isnât found or there are several fields with the given name.
Examples
>>> import pyarrow as pa >>> struct_type = pa.struct({'x': pa.int32(), 'y': pa.string()})
Index of the field with a name âyâ:
>>> struct_type.get_field_index('y') 1
Index of the field that does not exist:
>>> struct_type.get_field_index('z') -1
If True, the number of expected buffers is only lower-bounded by num_buffers.
Examples
>>> import pyarrow as pa >>> pa.int64().has_variadic_buffers False >>> pa.string_view().has_variadic_buffers True
Lists the field names.
Examples
>>> import pyarrow as pa >>> struct_type = pa.struct([('a', pa.int64()), ('b', pa.float64()), ('c', pa.string())]) >>> struct_type.names ['a', 'b', 'c']
Number of data buffers required to construct Array type excluding children.
Examples
>>> import pyarrow as pa >>> pa.int64().num_buffers 2 >>> pa.string().num_buffers 3
The number of child fields.
Examples
>>> import pyarrow as pa >>> pa.int64() DataType(int64) >>> pa.int64().num_fields 0 >>> pa.list_(pa.string()) ListType(list<item: string>) >>> pa.list_(pa.string()).num_fields 1 >>> struct = pa.struct({'x': pa.int32(), 'y': pa.string()}) >>> struct.num_fields 2
Return the equivalent NumPy / Pandas dtype.
Examples
>>> import pyarrow as pa >>> pa.int64().to_pandas_dtype() <class 'numpy.int64'>
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4