ak.with_field#
Defined in awkward.operations.ak_with_field on line 21.
- ak.with_field(array, what, where=None, *, highlevel=True, behavior=None, attrs=None)#
- Parameters:
array – Array-like data (anything
ak.to_layout
recognizes).what – Array-like data (anything
ak.to_layout
recognizes) to add as a new field.where (None or str or non-empy sequence of str) – If None, the new field has no name (can be accessed as an integer slot number in a string); If str, the name of the new field. If a sequence, it is interpreted as a path where to add the field in a nested record.
highlevel (bool) – If True, return an
ak.Array
; otherwise, return a low-levelak.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 ak.Array
or ak.Record
(or low-level equivalent, if
highlevel=False
) with a new field attached. This function does not
change the array in-place.
See ak.Array.__setitem__
and ak.Record.__setitem__
for a variant that
changes the high-level object in-place. (These methods internally use
ak.with_field
, so performance is not a factor in choosing one over the
other.)