ak.Record — Awkward Array 2.8.2 documentation (original) (raw)

Defined in awkward.highlevel on line 1791.

class ak.Record(self, data, *, behavior=None, with_name=None, check_valid=False, backend=None, attrs=None, named_axis=None)#

Parameters:

High-level record that can contain fields of any type.

Most users won’t be creating Records manually. This class primarily exists to be overridden in the same way as ak.Array.

Records can be used in Numba: they can be passed as arguments to a Numba-compiled function or returned as return values. The only limitation is that they cannot be _created_inside the Numba-compiled function; to make outputs, considerak.ArrayBuilder.

See also ak.Array and ak.behavior.

ak.Record.__init_subclass__(cls)#

ak.Record._update_class(self)#

ak.Record.attrs#

The mapping containing top-level metadata, which is serialised with the record during pickling.

Keys prefixed with @ are identified as “transient” attributes which are discarded prior to pickling, permitting the storage of non-pickleable types.

ak.Record.layout#

The ak.record.Record that contains composable ak.contents.Contentelements to determine how the array is structured.

See ak.Array.layout for a more complete description.

The ak.record.Record is not a subclass of ak.contents.Content in Python and it is not composable with them: ak.record.Record contains one ak.contents.RecordArray (which is a ak.contents.Content), butak.contents.Content nodes cannot contain a ak.record.Record.

A ak.record.Record is not an independent entity from itsak.contents.RecordArray; it’s really just a marker indicating which element to select. The XML representation reflects that:

vectors = ak.Array([{"x": 0.1, "y": 1.0, "z": 30.0}, ... {"x": 0.2, "y": 2.0, "z": 20.0}, ... {"x": 0.3, "y": 3.0, "z": 10.0}]) vectors[1].layout [0.1 0.2 0.3] [1. 2. 3.] [30. 20. 10.]

ak.Record.behavior#

The behavior parameter passed into this Record’s constructor.

See ak.behavior for a list of recognized key patterns and their meanings.

ak.Record.positional_axis#

ak.Record.named_axis#

ak.Record.tolist(self)#

Converts this Record into Python objects; same as ak.to_list(but without the underscore, like NumPy’stolist).

ak.Record.to_list(self)#

Converts this Record into Python objects; same as ak.to_list.

ak.Record.nbytes#

The total number of bytes in all the ak.index.Index, and ak.contents.NumpyArray buffers in this array tree.

It does not count buffers that must be kept in memory because of ownership, but are not directly used in the array. Nor does it count the (small) Python objects that reference the (large) array buffers.

ak.Record.fields#

List of field names or tuple slot numbers (as strings) of this record.

If this is actually a tuple its fields are string representations of integers, such as "0", "1", "2", etc.

See also ak.fields.

ak.Record.is_tuple#

If True, the top-most record structure has no named fields, i.e. it’s a tuple.

ak.Record._ipython_key_completions_(self)#

ak.Record.__iter__ = None#

ak.Record.type#

The high-level type of this Record; same as ak.type.

Note that the outermost element of a Record’s type is always anak.types.ScalarType, which .

The type of a ak.record.Record (from ak.Array.layout) is not wrapped by an ak.types.ScalarType.

ak.Record.typestr#

The high-level type of this Record, presented as a string.

ak.Record.__getitem__(self, where)#

Parameters:

where (many types supported; see below) – Index of positions to select from this Record.

Select items from the Record using an extension of NumPy’s (already quite extensive) rules.

See ak.Array.__getitem__ for a more complete description. Since this is a record, the first item in the slice tuple must be a string, selecting a field.

For example, with

record = ak.Record({"x": 3.3, "y": [1, 2, 3]})

we can select

record["x"] 3.3 record["y"] <Array [1, 2, 3] type='3 * int64'> record["y", 1] 2

ak.Record.__setitem__(self, where, what)#

Parameters:

For example:

record = ak.Record({"x": 3.3}) record["y"] = 4 record["z"] = {"another": "record"} record.show() {x: 3.3, y: 4, z: {another: 'record'}}

See ak.with_field for a variant that does not change the ak.Recordin-place. (Internally, this method uses ak.with_field, so performance is not a factor in choosing one over the other.)

ak.Record.__delitem__(self, where)#

Parameters:

where (str or tuple of str) – Field name to remove from the record.

For example:

record = ak.Record({"x": 3.3, "y": {"this": 10, "that": 20}}) del record["y", "that"] record.show() {x: 3.3, y: {this: 10}}

See ak.without_field for a variant that does not change the ak.Recordin-place. (Internally, this method uses ak.without_field, so performance is not a factor in choosing one over the other.)

ak.Record.__getattr__(self, where)#

Whenever possible, fields can be accessed as attributes.

For example, the fields of

record = ak.Record({"x": 1.1, "y": [2, 2], "z": "three"})

can be accessed as

record.x 1.1 record.y <Array [2, 2] type='2 * int64'> record.z 'three'

which are equivalent to record["x"], record["y"], andrecord["z"].

Fields can’t be accessed as attributes when

ak.Record.__setattr__(self, name, value)#

Parameters:

where (str) – Attribute name to set

Set an attribute on the record.

Only existing public attributes e.g. ak.Record.layout, or private attributes (with leading underscores), can be set.

Fields are not assignable to as attributes, i.e. the following doesn’t work:

Instead, always use ak.Record.__setitem__:

or ak.with_field:

record = ak.with_field(record, new_field, "z")

to add or modify a field.

ak.Record.__dir__(self)#

Lists all methods, properties, and field names (see __getattr__) that can be accessed as attributes.

ak.Record.__str__(self)#

ak.Record.__repr__(self)#

ak.Record._repr(self, limit_cols)#

ak.Record.show(self, limit_rows=20, limit_cols=80, *, type=False, named_axis=False, nbytes=False, backend=False, all=False, stream=STDOUT, formatter=None, precision=3)#

Parameters:

Display the contents of the array within limit_rows and limit_cols, using ellipsis (...) for hidden nested data.

The formatter argument controls the formatting of individual values, c.f.https://numpy.org/doc/stable/reference/generated/numpy.set_printoptions.htmlAs Awkward Array does not implement strings as a NumPy dtype, the numpystrkey is ignored; instead, a "bytes" and/or "str" key is considered when formatting string values, falling back upon "str_kind".

ak.Record._repr_mimebundle_(self, include=None, exclude=None)#

ak.Record.__array_ufunc__(self, ufunc, method, *inputs)#

Intercepts attempts to pass this Record to a NumPyuniversal functions(ufuncs) and passes it through the Record’s structure.

This method conforms to NumPy’sNEP 13for overriding ufuncs, which has beenavailable since NumPy 1.13(and thus NumPy 1.13 is the minimum allowed version).

See ak.Array.__array_ufunc__ for a more complete description.

ak.Record.numba_type#

The type of this Record when it is used in Numba. It contains enough information to generate low-level code for accessing any element, down to the leaves.

See Numba documentationon types and signatures.

ak.Record.__reduce_ex__(self, protocol)#

ak.Record.__setstate__(self, state)#

ak.Record.__copy__(self)#

ak.Record.__deepcopy__(self, memo)#

ak.Record.__bool__(self)#