ak.full_like
------------

Defined in `awkward.operations.structure <https://github.com/scikit-hep/awkward-1.0/blob/80bbef0738a6b7928333d7c705ee1b359991de5b/src/awkward/operations/structure.py>`__ on `line 1159 <https://github.com/scikit-hep/awkward-1.0/blob/80bbef0738a6b7928333d7c705ee1b359991de5b/src/awkward/operations/structure.py#L1159>`__.

.. py:function:: ak.full_like(array, fill_value, highlevel=True, behavior=None, dtype=None)


    :param array: Array to use as a model for a replacement that contains only
              ``fill_value``.
    :param fill_value: Value to fill new new array with.
    :param highlevel: If True, return an :py:obj:`ak.Array`;
                  otherwise, return a low-level :py:obj:`ak.layout.Content` subclass.
    :type highlevel: bool, default is True
    :param behavior: Custom :py:obj:`ak.behavior` for the output array, if
                 high-level.
    :type behavior: None or dict
    :param dtype: Overrides the data type of the result.
    :type dtype: None or type

This is the equivalent of NumPy's ``np.full_like`` for Awkward Arrays.

Although it's possible to produce an array of ``fill_value`` with the structure
of an ``array`` using :py:obj:`ak.broadcast_arrays`:

.. code-block:: python


    >>> array = ak.Array([[1, 2, 3], [], [4, 5]])
    >>> ak.broadcast_arrays(array, 1)
    [<Array [[1, 2, 3], [], [4, 5]] type='3 * var * int64'>,
     <Array [[1, 1, 1], [], [1, 1]] type='3 * var * int64'>]
    >>> ak.broadcast_arrays(array, 1.0)
    [<Array [[1, 2, 3], [], [4, 5]] type='3 * var * int64'>,
     <Array [[1, 1, 1], [], [1, 1]] type='3 * var * float64'>]

Such a technique takes its type from the scalar (``1`` or ``1.0``), rather than
the array. This function gets all types from the array, which might not be
the same in all parts of the structure.

Here is an extreme example:

.. code-block:: python


    >>> array = ak.Array([
    ... [{"x": 0.0, "y": []},
    ...  {"x": 1.1, "y": [1]},
    ...  {"x": 2.2, "y": [1, 2]}],
    ... [],
    ... [{"x": 3.3, "y": [1, 2, None, 3]},
    ...  False,
    ...  False,
    ...  True,
    ...  {"x": 4.4, "y": [1, 2, None, 3, 4]}]])
    >>> ak.to_list(ak.full_like(array, 12.3))
    [[{"x": 12.3, "y": []},
      {"x": 12.3, "y": [12]},
      {"x": 12.3, "y": [12, 12]}],
     [],
     [{"x": 12.3, "y": [12, 12, None, 12]},
      True,
      True,
      True,
      {"x": 12.3, "y": [12, 12, None, 12, 12]}]]

The ``"x"`` values get filled in with ``12.3`` because they retain their type
(``float64``) and the ``"y"`` list items get filled in with ``12`` because they
retain their type (``int64``). Booleans get filled with True because ``12.3``
is not zero. Missing values remain in the same positions as in the original
``array``. (To fill them in, use :py:obj:`ak.fill_none`.)

See also :py:obj:`ak.zeros_like` and :py:obj:`ak.ones_like`.

(There is no equivalent of NumPy's ``np.empty_like`` because Awkward Arrays
are immutable.)

