Skip to main content

Label the rows, columns, any dimension, of your NumPy arrays.

Project description

The main class of the la package is a labeled array, larry. A larry consists of data and labels. The data is stored as a NumPy array and the labels as a list of lists (one list per dimension).

Here’s larry in schematic form:

             date1    date2    date3
    'AAPL'   209.19   207.87   210.11
y = 'IBM'    129.03   130.39   130.55
    'DELL'    14.82    15.11    14.94

The larry above is stored internally as a Numpy array and a list of lists:

y.label = [['AAPL', 'IBM', 'DELL'], [date1, date2, date3]]
y.x = np.array([[209.19, 207.87, 210.11],
                [129.03, 130.39, 130.55],
                [ 14.82,  15.11,  14.94]])

A larry can have any number of dimensions except zero. Here, for example, is one way to create a one-dimensional larry:

>>> import la
>>> y = la.larry([1, 2, 3])

In the statement above the list is converted to a Numpy array and the labels default to range(n), where n in this case is 3.

larry has built-in methods such as movingsum, ranking, merge, shuffle, zscore, demean, lag as well as typical Numpy methods like sum, max, std, sign, clip. NaNs are treated as missing data.

Alignment by label is automatic when you add (or subtract, multiply, divide) two larrys.

You can archive larrys in HDF5 format using save and load or using a dictionary-like interface:

>>> io = la.IO('/tmp/dataset.hdf5')
>>> io['y'] = y   # <--- save
>>> z = io['y']   # <--- load
>>> del io['y']   # <--- delete from archive

For the most part larry acts like a Numpy array. And, whenever you want, you have direct access to the Numpy array that holds your data. For example if you have a function, myfunc, that works on Numpy arrays and doesn’t change the shape or ordering of the array, then you can use it on a larry, y, like this:

y.x = myfunc(y.x)

larry adds the convenience of labels, provides many built-in methods, and let’s you use your existing array functions.

docs

http://berkeleyanalytics.com/la

code

http://github.com/kwgoodman/la

issues

http://github.com/kwgoodman/la/issues

list

http://groups.google.com/group/labeled-array

This is an old version. Click here for latest version

Project details


Download files

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

Source Distribution

la-0.3.0.tar.gz (164.9 kB view details)

Uploaded Source

File details

Details for the file la-0.3.0.tar.gz.

File metadata

  • Download URL: la-0.3.0.tar.gz
  • Upload date:
  • Size: 164.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for la-0.3.0.tar.gz
Algorithm Hash digest
SHA256 54791214fb44fc00449466c22029afbf7bc2214546486ab13c40e6e717f2f44b
MD5 c56036e802aeafa73fcc6fc088657ef9
BLAKE2b-256 34fb0732341806c46d6d77e9d8e2b0d4aa91679166ab527e32bc9a89c0d2e4d2

See more details on using hashes here.

Supported by

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