ak.contents.IndexedArray#

Defined in awkward.contents.indexedarray on line 55.

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

IndexedArray is a general-purpose tool for lazily changing the order of and/or duplicating some content with a np.take over the integer buffer ``index.

It has many uses:

  • representing a lazily applied slice.

  • simulating pointers into another collection.

  • emulating the dictionary encoding of Apache Arrow and Parquet.

If the __array__ parameter is "categorical", the contents must be unique. Some operations are optimized (for instance, == only compares index integers) and the array can be converted to and from Arrow/Parquet’s dictionary encoding.

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

class IndexedArray(Content):
    def __init__(self, index, content):
        assert isinstance(index, (Index32, IndexU32, Index64))
        assert isinstance(content, Content)
        for x in index:
            assert 0 <= x < len(content)  # index[i] must not 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)
            return self.content[self.index[where]]

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

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

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