Awkward 0.x Array

0.15.5 · deprecated · verified Thu Apr 16

Awkward0 is a Python library for manipulating arrays of complex, nested, and variable-length data structures with the ease and performance of NumPy. It extends NumPy's vectorized operations to handle "jagged" or "ragged" arrays, records, mixed types, and missing data. This version (0.x) is pure Python and NumPy-based, offering columnar data access and efficient calculations on non-rectangular data. It is currently in a deprecated state, with development focused on the `awkward` (formerly `awkward1`) package.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates creating an `awkward0` array from nested Python lists, performing a vectorized NumPy operation on it, accessing elements using array slicing, and converting it back to a standard Python list of lists. `awkward0.fromiter` is a common way to initialize arrays from arbitrary Python structures, though it can be slow for large datasets.

import awkward0
import numpy as np

# Create a jagged array from a Python list of lists
array = awkward0.fromiter([[1.1, 2.2, None], [3.3], [4.4, 5.5, 6.6, None]])
print('Original array:')
print(array)

# Perform a vectorized operation (e.g., square root)
sqrt_array = np.sqrt(array)
print('\nSquare root of array:')
print(sqrt_array)

# Access elements using NumPy-like indexing
first_elements = array[:, 0]
print('\nFirst element of each sublist:')
print(first_elements)

# Convert back to a Python list of lists
list_representation = array.tolist()
print('\nList representation:')
print(list_representation)

view raw JSON →