ak.type#
Defined in awkward.operations.ak_type on line 21.
- ak.type(array, *, behavior=None)#
- Parameters:
array – Array-like data (anything
ak.to_layoutrecognizes).behavior (None or dict) – Custom
ak.behaviorfor the output type, if high-level.
The high-level type of an
array(many types supported, including all Awkward Arrays and Records) asak.types.Typeobjects.The high-level type ignores layout differences like
ak.contents.ListArrayversusak.contents.ListOffsetArray, but not differences like “regular-sized lists” (i.e.ak.contents.RegularArray) versus “variable-sized lists” (i.e.ak.contents.ListArrayand similar).Types are rendered as Datashape strings, which makes the same distinctions.
For example,
>>> array = ak.Array([[{"x": 1.1, "y": [1]}, {"x": 2.2, "y": [2, 2]}], ... [], ... [{"x": 3.3, "y": [3, 3, 3]}]])
has type
>>> ak.type(array).show() 3 * var * { x: float64, y: var * int64 }
but
>>> array = ak.Array(np.arange(2*3*5).reshape(2, 3, 5))
has type
>>> ak.type(array).show() 2 * 3 * 5 * int64
Some cases, like heterogeneous data, require [extensions beyond the Datashape specification](https://github.com/blaze/datashape/issues/237). For example,
>>> array = ak.Array([1, "two", [3, 3, 3]])
has type
>>> ak.type(array).show() 3 * union[ int64, string, var * int64 ]
but “union” is not a Datashape type-constructor. (Its syntax is similar to existing type-constructors, so it’s a plausible addition to the language.)