ak.broadcast_fields#

Defined in awkward.operations.ak_broadcast_fields on line 19.

ak.broadcast_fields(*arrays, highlevel=True, behavior=None, attrs=None)#
Parameters:
  • arrays – 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.

Return a list of arrays whose types contain the same number of fields. Unlike ak.broadcast_arrays, this function does not require record types to occur at the same depths. Where fields are missing from one record, they are inserted at the same position with an option[unknown] type. This type is easily erased by ufunc and concatenation operations.

>>> x, y = ak.broadcast_fields(
...     [{"x": {"y": 1, "z": 2, "w": [1]}}],
...     [{"x": [{"y": 1}]}],
... )
>>> x.type.show()
1 * {
    x: {
        y: int64,
        z: int64,
        w: var * int64
    }
}
>>> y.type.show()
1 * {
    x: var * {
        y: int64,
        z: ?unknown,
        w: ?unknown
    }
}