jorisvandenbossche commented on a change in pull request #7027:
URL: https://github.com/apache/arrow/pull/7027#discussion_r416374325
##########
File path: python/pyarrow/array.pxi
##########
@@ -1720,6 +1720,39 @@ cdef class UnionArray(Array):
Concrete class for Arrow arrays of a Union data type.
"""
+ def child(self, int pos):
+ """
+ Return the given child array as an individual array.
+
+ For sparse unions, the returned array has its offset, length,
+ and null count adjusted.
+
+ For dense unions, the returned array is unchanged.
+ """
+ cdef shared_ptr[CArray] result
+ result = (<CUnionArray*> self.ap).child(pos)
+ if result != NULL:
+ return pyarrow_wrap_array(result)
+ raise KeyError("UnionArray does not have child {}".format(pos))
+
+ @property
+ def type_codes(self):
+ """Get the type codes array."""
+ buf = pyarrow_wrap_buffer((<CUnionArray*> self.ap).type_codes())
+ return Array.from_buffers(int8(), len(self), [None, buf])
+
+ @property
+ def value_offsets(self):
Review comment:
For ListArray, this is called "offsets" (not sure if we prefer
consistency within the python api, or consistency with the c++ api)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]