Skip to main content

Manipulate arrays of complex data structures as easily as Numpy.

Project description

awkward-array

Calculations with rectangular, numerical data are simpler and faster in Numpy than traditional for loops. Consider, for instance,

all_r = []
for x, y in zip(all_x, all_y):
    all_r.append(sqrt(x**2 + y**2))

versus

all_r = sqrt(all_x**2 + all_y**2)

Not only is the latter easier to read, it’s hundreds of times faster than the for loop (and provides opportunities for hidden vectorization and parallelization). However, the Numpy abstraction stops at rectangular arrays of numbers or character strings. While it’s possible to put arbitrary Python data in a Numpy array, Numpy’s dtype=object is essentially a fixed-length list: data are not contiguous in memory and operations are not vectorized.

Awkward-array is a pure Python+Numpy library for manipulating complex data structures as you would Numpy arrays. Even if your data structures

  • contain variable-length lists (jagged/ragged),

  • are deeply nested (record structure),

  • have different data types in the same list (heterogeneous),

  • are masked, bit-masked, or index-mapped (nullable),

  • contain cross-references or even cyclic references,

  • need to be Python class instances on demand,

  • are not defined at every point (sparse),

  • are not contiguous in memory,

  • should not be loaded into memory all at once (lazy),

this library can access them as columnar data structures, with the efficiency of Numpy arrays. They may be converted from JSON or Python data, loaded from “awkd” files, HDF5, Parquet, or ROOT files, or they may be views into memory buffers like Arrow.

Note: feedback on this project informs the development of awkward-1.0, a reimplementation in C++ with a simpler user interface, coming in 2020. Leave comments about the future of awkward-array there (as GitHub issues or in the Google Docs).

Installation

Install awkward like any other Python package:

pip install awkward                       # maybe with sudo or --user, or in virtualenv

or install with conda:

conda config --add channels conda-forge   # if you haven't added conda-forge already
conda install awkward

The base awkward package requires only Numpy (1.13.1+).

Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

awkward-0.14.0.tar.gz (676.7 kB view details)

Uploaded Source

Built Distribution

awkward-0.14.0-py2.py3-none-any.whl (87.9 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file awkward-0.14.0.tar.gz.

File metadata

  • Download URL: awkward-0.14.0.tar.gz
  • Upload date:
  • Size: 676.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.1

File hashes

Hashes for awkward-0.14.0.tar.gz
Algorithm Hash digest
SHA256 6a3878f46e8bc2acf28a0b9feb69d354ad2fee2a2a0f65c48c115aa74f245204
MD5 636c96b3f4a76efe2fc2f53282d80011
BLAKE2b-256 6d07dd11c80b0307269f0283199bf84663025085dab14b83df2b52c1a210939c

See more details on using hashes here.

File details

Details for the file awkward-0.14.0-py2.py3-none-any.whl.

File metadata

  • Download URL: awkward-0.14.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 87.9 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.1

File hashes

Hashes for awkward-0.14.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 9f48acc50ea97ac4a57a8b7b7a8344e82d456a3df2514c82fb75308361394a3e
MD5 d6c4c9b9cd37ff5129510629b30e3c8e
BLAKE2b-256 4bca322dd25b102b03a0d8fefba037358a716e7ba2117b65839479071445a617

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page