- ak.argcartesian(arrays, axis=1, *, nested=None, parameters=None, with_name=None, highlevel=True, behavior=None)#
axis (int) – The dimension at which this operation is applied. The outermost dimension is
0, followed by
1, etc., and negative values count backward from the innermost:
-1is the innermost dimension,
-2is the next level up, etc.
nested (None, True, False, or iterable of str or int) – If None or False, all combinations of elements from the
arraysare produced at the same level of nesting; if True, they are grouped in nested lists by combinations that share a common item from each of the
arrays; if an iterable of str or int, group common items for a chosen set of keys from the
arraydict or slots of the
For example, the Cartesian product of
>>> one = ak.Array([1.1, 2.2, 3.3]) >>> two = ak.Array(["a", "b"])
>>> ak.cartesian([one, two], axis=0).show() [(1.1, 'a'), (1.1, 'b'), (2.2, 'a'), (2.2, 'b'), (3.3, 'a'), (3.3, 'b')]
But with argcartesian, only the indexes are returned.
>>> ak.argcartesian([one, two], axis=0).show() [(0, 0), (0, 1), (1, 0), (1, 1), (2, 0), (2, 1)]
These are the indexes that can select the items that go into the actual Cartesian product.
>>> one_index, two_index = ak.unzip(ak.argcartesian([one, two], axis=0)) >>> one[one_index] <Array [1.1, 1.1, 2.2, 2.2, 3.3, 3.3] type='6 * float64'> >>> two[two_index] <Array ['a', 'b', 'a', 'b', 'a', 'b'] type='6 * string'>