This is an automated email from the ASF dual-hosted git repository.
alenka pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/master by this push:
new 53e850a943 ARROW-17047: [Python][Docs] Document how to get field from
StructType (#13642)
53e850a943 is described below
commit 53e850a943950ff6e2540da56468474c622fc8e9
Author: Anja Kefala <[email protected]>
AuthorDate: Mon Jul 18 21:29:25 2022 -0700
ARROW-17047: [Python][Docs] Document how to get field from StructType
(#13642)

Umbrella issue: https://issues.apache.org/jira/browse/ARROW-17048
Authored-by: anjakefala <[email protected]>
Signed-off-by: Alenka Frim <[email protected]>
---
python/pyarrow/types.pxi | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/python/pyarrow/types.pxi b/python/pyarrow/types.pxi
index 0d96127842..894dd9617f 100644
--- a/python/pyarrow/types.pxi
+++ b/python/pyarrow/types.pxi
@@ -421,6 +421,23 @@ cdef class FixedSizeListType(DataType):
cdef class StructType(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
+ --------
+ >>> import pyarrow as pa
+ >>> struct_type = pa.struct({'x': pa.int32(), 'y': pa.string()})
+ >>> struct_type[0]
+ pyarrow.Field<x: int32>
+ >>> struct_type['y']
+ pyarrow.Field<y: string>
+
+ >>> pa.schema(list(struct_type))
+ x: int32
+ y: string
"""
cdef void init(self, const shared_ptr[CDataType]& type) except *: