ak.to_numpy#
Defined in awkward.operations.ak_to_numpy on line 13.
- ak.to_numpy(array, *, allow_missing=True)#
- Parameters:
array – Array-like data (anything
ak.to_layoutrecognizes).allow_missing (bool) – allow missing (None) values.
Converts
array(many types supported, including all Awkward Arrays and Records) into a NumPy array, if possible.If the data are numerical and regular (nested lists have equal lengths in each dimension, as described by the
ak.Array.type), they can be losslessly converted to a NumPy array and this function returns without an error.Otherwise, the function raises an error. It does not create a NumPy array with dtype
"O"fornp.object_(see the note on object_ type) since silent conversions to dtype"O"arrays would not only be a significant performance hit, but would also break functionality, since nested lists in a NumPy"O"array are severed from the array and cannot be sliced as dimensions.If
arrayis not an Awkward Array, then this function is equivalent to callingnp.asarrayon it.If
allow_missingis True; NumPy masked arrays are a possible result; otherwise, missing values (None) cause this function to raise an error.See also
ak.from_numpyandak.to_cupy.