ak.argcartesian
---------------

.. py:module: ak.argcartesian

Defined in `awkward.operations.ak_argcartesian <https://github.com/scikit-hep/awkward/blob/36da52cfa8846355c390beb6555eac1d31c27c26/src/awkward/operations/ak_argcartesian.py>`__ on `line 17 <https://github.com/scikit-hep/awkward/blob/36da52cfa8846355c390beb6555eac1d31c27c26/src/awkward/operations/ak_argcartesian.py#L17>`__.

.. py:function:: ak.argcartesian(arrays, axis=1, *, nested=None, parameters=None, with_name=None, highlevel=True, behavior=None, attrs=None)


    :param arrays: Each value in this mapping or
               sequence can be any array-like data that :py:obj:`ak.to_layout` recognizes.
    :type arrays: mapping or sequence of arrays
    :param axis: 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: ``-1`` is the innermost
             dimension, ``-2`` is the next level up, etc.
    :type axis: int
    :param nested: If None or
               False, all combinations of elements from the ``arrays`` are
               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 ``array`` dict or slots
               of the ``array`` iterable.
    :type nested: None, True, False, or iterable of str or int
    :param parameters: Parameters for the new
                   :py:obj:`ak.contents.RecordArray` node that is created by this operation.
    :type parameters: None or dict
    :param with_name: Assigns a ``"__record__"`` name to the new
                  :py:obj:`ak.contents.RecordArray` node that is created by this operation
                  (overriding ``parameters``, if necessary).
    :type with_name: None or str
    :param highlevel: If True, return an :py:obj:`ak.Array`; otherwise, return
                  a low-level :py:obj:`ak.contents.Content` subclass.
    :type highlevel: bool
    :param behavior: Custom :py:obj:`ak.behavior` for the output array, if
                 high-level.
    :type behavior: None or dict
    :param attrs: Custom attributes for the output array, if
              high-level.
    :type attrs: None or dict

Computes a Cartesian product (i.e. cross product) of data from a set of
``arrays``, like :py:obj:`ak.cartesian`, but returning integer indexes for
:py:obj:`ak.Array.__getitem__`.

For example, the Cartesian product of

.. code-block:: python


    >>> one = ak.Array([1.1, 2.2, 3.3])
    >>> two = ak.Array(["a", "b"])

is

.. code-block:: python


    >>> 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.

.. code-block:: python


    >>> 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.

.. code-block:: python


    >>> 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'>

All of the parameters for :py:obj:`ak.cartesian` apply equally to :py:obj:`ak.argcartesian`,
so see the :py:obj:`ak.cartesian` documentation for a more complete description.