ak.values_astype

Defined in awkward.operations.structure on line 4206.

ak.values_astype(array, to, highlevel=True, behavior=None)
Parameters
  • array – Array whose numbers should be converted to a new numeric type.

  • to (dtype or dtype specifier) – Type to convert the numbers into.

  • highlevel (bool) – If True, return an ak.Array; otherwise, return a low-level ak.layout.Content subclass.

  • behavior (None or dict) – Custom ak.behavior for the output array, if high-level.

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

For example,

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

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

See also ak.strings_astype.