ak.ravel#

Defined in awkward.operations.ak_ravel on line 17.

ak.ravel(array, *, highlevel=True, behavior=None, attrs=None)#
Parameters:
  • array – Array-like data (anything ak.to_layout recognizes).

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

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

  • attrs (None or dict) – Custom attributes 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:

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

>>> ak.ravel(array).show()
[1.1,
 2.2,
 3.3,
 4.4,
 5.5,
 6.6,
 7.7,
 8.8,
 9.9]

Missing values are not eliminated by flattening. See ak.flatten with axis=None for an equivalent function that eliminates the option type.