ak.contents.IndexedOptionArray#

Defined in awkward.contents.indexedoptionarray on line 54.

class ak.contents.IndexedOptionArray(self, index, content, *, parameters=None)#

IndexedOptionArray is an ak.contents.IndexedArray for which negative values in the index are interpreted as missing. It represents ak.types.OptionType data like ak.contents.ByteMaskedArray, ak.contents.BitMaskedArray, and ak.contents.UnmaskedArray, but the flexibility of the arbitrary index makes it a common output of many operations.

IndexedOptionArray doesn’t have a direct equivalent in Apache Arrow.

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

class IndexedOptionArray(Content):
    def __init__(self, index, content):
        assert isinstance(index, (Index32, Index64))
        assert isinstance(content, Content)
        for x in index:
            assert x < len(content)  # index[i] may be negative
        self.index = index
        self.content = content

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

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

        elif isinstance(where, slice) and where.step is None:
            return IndexedOptionArray(
                self.index[where.start : where.stop], self.content
            )

        elif isinstance(where, str):
            return IndexedOptionArray(self.index, self.content[where])

        else:
            raise AssertionError(where)
ak.contents.IndexedOptionArray.index#
ak.contents.IndexedOptionArray.copy(self, index=UNSET, content=UNSET, *, parameters=UNSET)#
ak.contents.IndexedOptionArray.__copy__(self)#
ak.contents.IndexedOptionArray.__deepcopy__(self, memo)#
ak.contents.IndexedOptionArray.simplified(cls, index, content, *, parameters=None)#
ak.contents.IndexedOptionArray._form_with_key(self, getkey)#
ak.contents.IndexedOptionArray._to_buffers(self, form, getkey, container, backend, byteorder)#
ak.contents.IndexedOptionArray._to_typetracer(self, forget_length)#
ak.contents.IndexedOptionArray._touch_data(self, recursive)#
ak.contents.IndexedOptionArray._touch_shape(self, recursive)#
ak.contents.IndexedOptionArray.length#
ak.contents.IndexedOptionArray.__repr__(self)#
ak.contents.IndexedOptionArray._repr(self, indent, pre, post)#
ak.contents.IndexedOptionArray.to_IndexedOptionArray64(self)#
ak.contents.IndexedOptionArray.to_ByteMaskedArray(self, valid_when)#
ak.contents.IndexedOptionArray.to_BitMaskedArray(self, valid_when, lsb_order)#
ak.contents.IndexedOptionArray.mask_as_bool(self, valid_when=True)#
ak.contents.IndexedOptionArray._getitem_nothing(self)#
ak.contents.IndexedOptionArray._is_getitem_at_placeholder(self)#
ak.contents.IndexedOptionArray._getitem_at(self, where)#
ak.contents.IndexedOptionArray._getitem_range(self, start, stop)#
ak.contents.IndexedOptionArray._getitem_field(self, where, only_fields=())#
ak.contents.IndexedOptionArray._getitem_fields(self, where, only_fields=())#
ak.contents.IndexedOptionArray._carry(self, carry, allow_lazy)#
ak.contents.IndexedOptionArray._nextcarry_outindex(self)#
ak.contents.IndexedOptionArray._getitem_next_jagged_generic(self, slicestarts, slicestops, slicecontent, tail)#
ak.contents.IndexedOptionArray._getitem_next_jagged(self, slicestarts, slicestops, slicecontent, tail)#
ak.contents.IndexedOptionArray._getitem_next(self, head, tail, advanced)#
ak.contents.IndexedOptionArray.project(self, mask=None)#
ak.contents.IndexedOptionArray._offsets_and_flattened(self, axis, depth)#
ak.contents.IndexedOptionArray._mergeable_next(self, other, mergebool)#
ak.contents.IndexedOptionArray._merging_strategy(self, others)#
ak.contents.IndexedOptionArray._reverse_merge(self, other)#
ak.contents.IndexedOptionArray._mergemany(self, others)#
ak.contents.IndexedOptionArray._fill_none(self, value)#
ak.contents.IndexedOptionArray._local_index(self, axis, depth)#
ak.contents.IndexedOptionArray._is_subrange_equal(self, starts, stops, length, sorted=True)#
ak.contents.IndexedOptionArray._numbers_to_type(self, name, including_unknown)#
ak.contents.IndexedOptionArray._is_unique(self, negaxis, starts, parents, outlength)#
ak.contents.IndexedOptionArray._unique(self, negaxis, starts, parents, outlength)#
ak.contents.IndexedOptionArray._rearrange_nextshifts(self, nextparents, shifts)#
ak.contents.IndexedOptionArray._rearrange_prepare_next(self, parents)#
ak.contents.IndexedOptionArray._argsort_next(self, negaxis, starts, shifts, parents, outlength, ascending, stable)#
ak.contents.IndexedOptionArray._sort_next(self, negaxis, starts, parents, outlength, ascending, stable)#
ak.contents.IndexedOptionArray._reduce_next(self, reducer, negaxis, starts, shifts, parents, outlength, mask, keepdims, behavior)#
ak.contents.IndexedOptionArray._combinations(self, n, replacement, recordlookup, parameters, axis, depth)#
ak.contents.IndexedOptionArray._validity_error(self, path)#
ak.contents.IndexedOptionArray._nbytes_part(self)#
ak.contents.IndexedOptionArray._pad_none(self, target, axis, depth, clip)#
ak.contents.IndexedOptionArray._to_arrow(self, pyarrow, mask_node, validbytes, length, options)#
ak.contents.IndexedOptionArray._to_cudf(self, cudf, mask, length)#
ak.contents.IndexedOptionArray._to_backend_array(self, allow_missing, backend)#
ak.contents.IndexedOptionArray._remove_structure(self, backend, options)#
ak.contents.IndexedOptionArray._drop_none(self)#
ak.contents.IndexedOptionArray._recursively_apply(self, action, depth, depth_context, lateral_context, options)#
ak.contents.IndexedOptionArray.to_packed(self, recursive=True)#
ak.contents.IndexedOptionArray._to_list(self, behavior, json_conversions)#
ak.contents.IndexedOptionArray._to_backend(self, backend)#
ak.contents.IndexedOptionArray._is_equal_to(self, other, index_dtype, numpyarray, all_parameters)#
ak.contents.IndexedOptionArray._trim(self)#