ak.values_astype
----------------

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

.. py:function:: ak.values_astype(array, to, highlevel=True, behavior=None)


    :param array: Array whose numbers should be converted to a new numeric type.
    :param to: Type to convert the numbers into.
    :type to: dtype or dtype specifier
    :param highlevel: If True, return an :py:obj:`ak.Array`; otherwise, return
                  a low-level :py:obj:`ak.layout.Content` subclass.
    :type highlevel: bool
    :param behavior: Custom :py:obj:`ak.behavior` for the output array, if
                 high-level.
    :type behavior: None or dict

Converts all numbers in the array to a new type, leaving the structure
untouched.

For example,

.. code-block:: python


    >>> array = ak.Array([1.1, 2.2, 3.3, 4.4, 5.5])
    >>> ak.values_astype(array, np.int32)
    <Array [1, 2, 3, 4, 5] type='5 * int32'>

and

.. code-block:: python


    >>> array = ak.Array([[1.1, 2.2, 3.3], [], [4.4, 5.5]])
    >>> ak.values_astype(array, np.int32)
    <Array [[1, 2, 3], [], [4, 5]] type='3 * var * int32'>

Note, when converting values to a ``np.datetime64`` type that is unitless, a
default '[us]' unit is assumed - until further specified as numpy dtypes.

For example,

.. code-block:: python


    >>> array = ak.Array([1567416600000])
    >>> ak.values_astype(array, "datetime64[ms]")
    <Array [2019-09-02T09:30:00.000] type='1 * datetime64'>

or

.. code-block:: python


    >>> array = ak.Array([1567416600000])
    >>> ak.values_astype(array, np.dtype("M8[ms]"))
    <Array [2019-09-02T09:30:00.000] type='1 * datetime64'>

See also :py:obj:`ak.strings_astype`.

