ak.contents.UnionArray — Awkward Array 2.8.2 documentation (original) (raw)

Defined in awkward.contents.unionarray on line 57.

class ak.contents.UnionArray(self, tags, index, contents, *, parameters=None)#

UnionArray represents data drawn from an ordered list of contents, which can have different types, using

UnionArrays correspond to Apache Arrow’sdense union type. Awkward Array has no direct equivalent for Apache Arrow’ssparse union type.

To illustrate how the constructor arguments are interpreted, the following is a simplified implementation of __init__, __len__, and __getitem__:

class UnionArray(Content): def init(self, tags, index, contents): assert isinstance(tags, Index8) assert isinstance(index, (Index32, IndexU32, Index64)) assert isinstance(contents, list) assert len(index) >= len(tags) # usually equal for x in tags: assert 0 <= x < len(contents) for i, x in enumerate(tags): assert 0 <= index[i] < len(contents[x]) self.tags = tags self.index = index self.contents = contents

def __len__(self):
    return len(self.tags)

def __getitem__(self, where):
    if isinstance(where, int):
        if where < 0:
            where += len(self)
        assert 0 <= where < len(self)
        return self.contents[self.tags[where]][self.index[where]]

    elif isinstance(where, slice) and where.step is None:
        return UnionArray(
            self.tags[where], self.index[where], self.contents
        )

    elif isinstance(where, str):
        return UnionArray(
            self.tags, self.index, [x[where] for x in self.contents]
        )

    else:
        raise AssertionError(where)

ak.contents.UnionArray.tags#

ak.contents.UnionArray.index#

ak.contents.UnionArray.copy(self, tags=UNSET, index=UNSET, contents=UNSET, *, parameters=UNSET)#

ak.contents.UnionArray.__copy__(self)#

ak.contents.UnionArray.__deepcopy__(self, memo)#

ak.contents.UnionArray.simplified(cls, tags, index, contents, *, parameters=None, mergebool=False)#

ak.contents.UnionArray._form_with_key(self, getkey)#

ak.contents.UnionArray._form_with_key_path(self, path)#

ak.contents.UnionArray._to_buffers(self, form, getkey, container, backend, byteorder)#

ak.contents.UnionArray._to_typetracer(self, forget_length)#

ak.contents.UnionArray._touch_data(self, recursive)#

ak.contents.UnionArray._touch_shape(self, recursive)#

ak.contents.UnionArray.length#

ak.contents.UnionArray.__repr__(self)#

ak.contents.UnionArray._repr(self, indent, pre, post)#

ak.contents.UnionArray._getitem_nothing(self)#

ak.contents.UnionArray._is_getitem_at_placeholder(self)#

ak.contents.UnionArray._is_getitem_at_virtual(self)#

ak.contents.UnionArray._getitem_at(self, where)#

ak.contents.UnionArray._getitem_range(self, start, stop)#

ak.contents.UnionArray._getitem_field(self, where, only_fields=())#

ak.contents.UnionArray._getitem_fields(self, where, only_fields=())#

ak.contents.UnionArray._carry(self, carry, allow_lazy)#

ak.contents.UnionArray._union_of_optionarrays(self, index, parameters)#

ak.contents.UnionArray.project(self, index)#

ak.contents.UnionArray.regular_index(tags, *, backend, index_cls=Index64)#

ak.contents.UnionArray._regular_index(self, tags)#

ak.contents.UnionArray.nested_tags_index(offsets, counts, *, backend, tags_cls=Index8, index_cls=Index64)#

ak.contents.UnionArray._getitem_next_jagged_generic(self, slicestarts, slicestops, slicecontent, tail)#

ak.contents.UnionArray._getitem_next_jagged(self, slicestarts, slicestops, slicecontent, tail)#

ak.contents.UnionArray._getitem_next(self, head, tail, advanced)#

ak.contents.UnionArray._offsets_and_flattened(self, axis, depth)#

ak.contents.UnionArray._mergeable_next(self, other, mergebool)#

ak.contents.UnionArray._merging_strategy(self, others)#

ak.contents.UnionArray._reverse_merge(self, other)#

ak.contents.UnionArray._mergemany(self, others)#

ak.contents.UnionArray._fill_none(self, value)#

ak.contents.UnionArray._local_index(self, axis, depth)#

ak.contents.UnionArray._combinations(self, n, replacement, recordlookup, parameters, axis, depth)#

ak.contents.UnionArray._numbers_to_type(self, name, including_unknown)#

ak.contents.UnionArray._is_unique(self, negaxis, starts, parents, outlength)#

ak.contents.UnionArray._unique(self, negaxis, starts, parents, outlength)#

ak.contents.UnionArray._argsort_next(self, negaxis, starts, shifts, parents, outlength, ascending, stable)#

ak.contents.UnionArray._sort_next(self, negaxis, starts, parents, outlength, ascending, stable)#

ak.contents.UnionArray._reduce_next(self, reducer, negaxis, starts, shifts, parents, outlength, mask, keepdims, behavior)#

ak.contents.UnionArray._validity_error(self, path)#

ak.contents.UnionArray._nbytes_part(self)#

ak.contents.UnionArray._pad_none(self, target, axis, depth, clip)#

ak.contents.UnionArray._to_arrow(self, pyarrow, mask_node, validbytes, length, options)#

ak.contents.UnionArray._to_backend_array(self, allow_missing, backend)#

ak.contents.UnionArray._remove_structure(self, backend, options)#

ak.contents.UnionArray._recursively_apply(self, action, depth, depth_context, lateral_context, options)#

ak.contents.UnionArray.to_packed(self, recursive=True)#

ak.contents.UnionArray._to_list(self, behavior, json_conversions)#

ak.contents.UnionArray._to_backend(self, backend)#

ak.contents.UnionArray._materialize(self)#

ak.contents.UnionArray._is_all_materialized#

ak.contents.UnionArray._is_any_materialized#

ak.contents.UnionArray._is_equal_to(self, other, index_dtype, numpyarray, all_parameters)#