Skip to content

Commit

Permalink
ARROW-17131: [Python] add public-facing field() to UnionType
Browse files Browse the repository at this point in the history
  • Loading branch information
anjakefala committed Jul 20, 2022
1 parent 10bc33e commit fa38227
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions python/pyarrow/types.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,23 @@ cdef class UnionType(DataType):
for i in range(len(self)):
yield self[i]

def field(self, i):
"""
Return a child field by its numeric index.
Parameters
----------
i : int
Returns
-------
pyarrow.Field
"""
if isinstance(i, int):
return DataType.field(self, i)
else:
raise TypeError('Expected integer')

def __getitem__(self, i):
"""
Return a child field by its index.
Expand Down

0 comments on commit fa38227

Please sign in to comment.