ak.ravel¶
Defined in awkward.operations.structure on line 2178.
- ak.ravel(array, highlevel=True, behavior=None)¶
- Parameters
array – Data containing nested lists to flatten
highlevel (bool) – If True, return an
ak.Array
; otherwise, return a low-levelak.layout.Content
subclass.behavior (None or dict) – Custom
ak.behavior
for the output array, if high-level.
Returns an array with all level of nesting removed by erasing the boundaries between consecutive lists.
This is the equivalent of NumPy’s np.ravel
for Awkward Arrays.
Consider the following doubly nested array
.
ak.Array([[
[1.1, 2.2, 3.3],
[],
[4.4, 5.5],
[6.6]],
[],
[
[7.7],
[8.8, 9.9]
]])
Ravelling the array produces a flat array
>>> print(ak.ravel(array))
[1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7, 8.8, 9.9]
Missing values are eliminated by flattening: there is no distinction between an empty list and a value of None at the level of flattening.