Awkward Array

2.9.0 · active · verified Sun Apr 12

Awkward Array is a Python library for manipulating nested, variable-sized data (like JSON) with NumPy-like idioms. It provides dynamically typed arrays that are compiled for fast operations, generalizing NumPy's behavior for irregular data structures. The library is actively developed with frequent releases, currently at version 2.9.0.

Warnings

Install

Imports

Quickstart

This example demonstrates creating an Awkward Array from a nested Python list of dictionaries and then performing a NumPy-like vectorized operation to slice and transform the data.

import awkward as ak
import numpy as np

array = ak.Array([
    [{"x": 1.1, "y": [1]}, {"x": 2.2, "y": [1, 2]}, {"x": 3.3, "y": [1, 2, 3]}],
    [],
    [{"x": 4.4, "y": [1, 2, 3, 4]}, {"x": 5.5, "y": [1, 2, 3, 4, 5]}]
])

# Slice out the y values, drop the first element from each inner list, and square them
output = np.square(array["y", ..., 1:])
print(output)

view raw JSON →