API Reference

Axis

Axis(labels[, name]) Represents an axis.

Exploring

Axis.name Name of the axis. None in the case of an anonymous axis.
Axis.labels Labels of the axis.
Axis.labels_summary Short representation of the labels.

Copying

Axis.copy() Returns a copy of the axis.

Searching

Axis.index(key[, bool_passthrough]) Translates a label key to its numerical index counterpart.
Axis.containing(substring) Returns a group with all the labels containing the specified substring.
Axis.startingwith(prefix) Returns a group with the labels starting with the specified string.
Axis.endingwith(suffix) Returns a group with the labels ending with the specified string.
Axis.matching(pattern) Returns a group with all the labels matching the specified pattern (regular expression).

Modifying/Selecting/Searching

Axis.__getitem__(key) Returns a group (list or unique element) of label(s) usable in .sum or .filter
Axis.i Allows to define a subset using positions along the axis instead of labels.
Axis.by(length[, step]) Split axis into several groups of specified length.
Axis.rename(name) Renames the axis.
Axis.subaxis(key[, name]) Returns an axis for a sub-array.
Axis.extend(labels) Append new labels to an axis or increase its length in case of wildcard axis.
Axis.insert(new_labels[, before, after]) Return a new axis with new_labels inserted before before or after after.
Axis.replace(old[, new]) Returns a new axis with some labels replaced.
Axis.union(other) Returns axis with the union of this axis labels and other labels.
Axis.intersection(other) Returns axis with the (set) intersection of this axis labels and other labels.
Axis.difference(other) Returns axis with the (set) difference of this axis labels and other labels.
Axis.align(other[, join]) Align axis with other object using specified join method.
Axis.split([sep, names, regex, return_labels]) Split axis and returns a list of Axis.

Testing

Axis.iscompatible(other) Checks if self is compatible with another axis.
Axis.equals(other) Checks if self is equal to another axis.

Group

IGroup

IGroup(key[, name, axis]) Index Group.
IGroup.named(name) Returns group with a different name.
IGroup.with_axis(axis) Returns group with a different axis.
IGroup.by(length[, step]) Split group into several groups of specified length.
IGroup.translate([bound, stop]) compute position(s) of group
IGroup.union(other) Returns (set) union of this label group and other.
IGroup.intersection(other) Returns (set) intersection of this label group and other.
IGroup.difference(other) Returns (set) difference of this label group and other.
IGroup.containing(substring) Returns a group with all the labels containing the specified substring.
IGroup.startingwith(prefix) Returns a group with the labels starting with the specified string.
IGroup.endingwith(suffix) Returns a group with the labels ending with the specified string.
IGroup.matching(pattern) Returns a group with all the labels matching the specified pattern (regular expression).

LGroup

LGroup(key[, name, axis]) Label group.
LGroup.named(name) Returns group with a different name.
LGroup.with_axis(axis) Returns group with a different axis.
LGroup.by(length[, step]) Split group into several groups of specified length.
LGroup.translate([bound, stop]) compute position(s) of group
LGroup.union(other) Returns (set) union of this label group and other.
LGroup.intersection(other) Returns (set) intersection of this label group and other.
LGroup.difference(other) Returns (set) difference of this label group and other.
LGroup.containing(substring) Returns a group with all the labels containing the specified substring.
LGroup.startingwith(prefix) Returns a group with the labels starting with the specified string.
LGroup.endingwith(suffix) Returns a group with the labels ending with the specified string.
LGroup.matching(pattern) Returns a group with all the labels matching the specified pattern (regular expression).

LSet

LSet(key[, name, axis]) Label set.

AxisCollection

AxisCollection([axes]) Represents a collection of axes.
AxisCollection.names Returns the list of (raw) names of the axes.
AxisCollection.display_names Returns the list of (display) names of the axes.
AxisCollection.labels Returns the list of labels of the axes.
AxisCollection.shape Returns the shape of the collection.
AxisCollection.size Returns the size of the collection, i.e.
AxisCollection.info Describes the collection (shape and labels for each axis).
AxisCollection.copy() Returns a copy.

Searching

AxisCollection.keys() Returns list of all axis names.
AxisCollection.index(axis) Returns the index of axis.
AxisCollection.translate_full_key(key) Translates a label-based key to a positional key.
AxisCollection.axis_id(axis) Returns the id of an axis.
AxisCollection.ids Returns the list of ids of the axes.

Modifying/Selecting

AxisCollection.get(key[, default, name]) Returns axis corresponding to key.
AxisCollection.get_by_pos(key, i) Returns axis corresponding to a key, or to position i if the key has no name and key object not found.
AxisCollection.get_all(key) Returns all axes from key if present and length 1 wildcard axes otherwise.
AxisCollection.pop([axis]) Removes and returns an axis.
AxisCollection.append(axis) Appends axis at the end of the collection.
AxisCollection.extend(axes[, validate, …]) Extends the collection by appending the axes from axes.
AxisCollection.insert(index, axis) Inserts axis before index.
AxisCollection.replace([axes_to_replace, …]) Replace one, several or all axes of the collection.
AxisCollection.without(axes) Returns a new collection without some axes.
AxisCollection.combine_axes([axes, sep, …]) Combine several axes into one.
AxisCollection.split_axes([axes, sep, …]) Split axes and returns a new collection
AxisCollection.align(other[, join, axes]) Align this axis collection with another.

Testing

AxisCollection.isaxis(value) Tests if input is an Axis object or the name of an axis contained in self.
AxisCollection.check_compatible(axes) Checks if axes passed as argument are compatible with those contained in the collection.

LArray

Overview

LArray(data[, axes, title]) A LArray object represents a multidimensional, homogeneous array of fixed-size items with labeled axes.

Array Creation Functions

sequence(axis[, initial, inc, mult, func, …]) Creates an array by sequentially applying modifications to the array along axis.
ndrange(axes[, start, title, dtype]) Returns an array with the specified axes and filled with increasing int.
ndtest(shape[, start, label_start, title, dtype]) Returns test array with given shape.
zeros(axes[, title, dtype, order]) Returns an array with the specified axes and filled with zeros.
zeros_like(array[, title, dtype, order]) Returns an array with the same axes as array and filled with zeros.
ones(axes[, title, dtype, order]) Returns an array with the specified axes and filled with ones.
ones_like(array[, title, dtype, order]) Returns an array with the same axes as array and filled with ones.
empty(axes[, title, dtype, order]) Returns an array with the specified axes and uninitialized (arbitrary) data.
empty_like(array[, title, dtype, order]) Returns an array with the same axes as array and uninitialized (arbitrary) data.
full(axes, fill_value[, title, dtype, order]) Returns an array with the specified axes and filled with fill_value.
full_like(array, fill_value[, title, dtype, …]) Returns an array with the same axes and type as input array and filled with fill_value.

Copying

LArray.copy() Returns a copy of the array.

Inspecting

LArray.data Data of the array (Numpy ndarray)
LArray.axes Axes of the array (AxisCollection)
LArray.title Title of the array (str)
LArray.info Describes a LArray (title + shape and labels for each axis).
LArray.shape Returns the shape of the array as a tuple.
LArray.ndim Returns the number of dimensions of the array.
LArray.dtype Returns the type of the data of the array.
LArray.size Returns the number of elements in array.
LArray.nbytes Returns the number of bytes used to store the array in memory.
LArray.memory_used Returns the memory consumed by the array in human readable form.
LArray.astype(dtype[, order, casting, …]) Copy of the array, cast to a specified type.

Modifying/Selecting

LArray.i Allows selection of a subset using indices of labels.
LArray.points Allows selection of arbitrary items in the array based on their N-dimensional label index.
LArray.ipoints Allows selection of arbitrary items in the array based on their N-dimensional index.
LArray.set(value, **kwargs) Sets a subset of array to value.
LArray.drop_labels([axes]) Drops the labels from axes (replace those axes by “wildcard” axes).
LArray.filter([collapse]) Filters the array along the axes given as keyword arguments.

Changing Axes or Labels

LArray.set_axes([axes_to_replace, new_axis, …]) Replace one, several or all axes of the array.
LArray.rename([renames, to, inplace]) Renames axes of the array.
LArray.set_labels([axis, labels, inplace]) Replaces the labels of an axis of array.
LArray.combine_axes([axes, sep, wildcard]) Combine several axes into one.
LArray.split_axes([axes, sep, names, regex, …]) Split axes and returns a new array

Aggregation Functions

LArray.sum(*axes_and_groups[, dtype, out, …]) Computes the sum of array elements along given axes/groups.
LArray.sum_by(*axes_and_groups[, dtype, …]) Computes the sum of array elements for the given axes/groups.
LArray.prod(*axes_and_groups[, dtype, out, …]) Computes the product of array elements along given axes/groups.
LArray.prod_by(*axes_and_groups[, dtype, …]) Computes the product of array elements for the given axes/groups.
LArray.cumsum([axis]) Returns the cumulative sum of array elements along an axis.
LArray.cumprod([axis]) Returns the cumulative product of array elements.
LArray.mean(*axes_and_groups[, dtype, out, …]) Computes the arithmetic mean.
LArray.mean_by(*axes_and_groups[, dtype, …]) Computes the arithmetic mean.
LArray.median(*axes_and_groups[, out, …]) Computes the arithmetic median.
LArray.median_by(*axes_and_groups[, out, …]) Computes the arithmetic median.
LArray.var(*axes_and_groups[, dtype, ddof, …]) Computes the unbiased variance.
LArray.var_by(*axes_and_groups[, dtype, …]) Computes the unbiased variance.
LArray.std(*axes_and_groups[, dtype, ddof, …]) Computes the sample standard deviation.
LArray.std_by(*axes_and_groups[, dtype, …]) Computes the sample standard deviation.
LArray.percentile(q, *axes_and_groups[, …]) Computes the qth percentile of the data along the specified axis.
LArray.percentile_by(q, *axes_and_groups[, …]) Computes the qth percentile of the data for the specified axis.
LArray.ptp(*axes_and_groups[, out]) Returns the range of values (maximum - minimum).
LArray.with_total(*args[, op, label]) Add aggregated values (sum by default) along each axis.
LArray.percent(*axes) Returns an array with values given as percent of the total of all values along given axes.
LArray.growth_rate([axis, d, label]) Calculates the growth along a given axis.
LArray.describe(*args, **kwargs) Descriptive summary statistics, excluding NaN values.
LArray.describe_by(*args, **kwargs) Descriptive summary statistics, excluding NaN values, along axes or for groups.

Sorting

LArray.sort_axes([axes, ascending]) Sorts axes of the array.
LArray.sort_values([key, axis, ascending]) Sorts values of the array.
LArray.labelsofsorted([axis, ascending, kind]) Returns the labels that would sort this array.
LArray.indicesofsorted([axis, ascending, kind]) Returns the indices that would sort this array.

Reshaping/Extending/Reordering

LArray.reshape(target_axes) Given a list of new axes, changes the shape of the array.
LArray.reshape_like(target) Same as reshape but with an array as input.
LArray.compact() Detects and removes “useless” axes (ie axes for which values are constant over the whole axis)
LArray.reindex([axes_to_reindex, new_axis, …]) Reorder and/or add new labels in axes.
LArray.transpose(*args) Reorder axes.
LArray.expand([target_axes, out, readonly]) Expands array to target_axes.
LArray.prepend(axis, value[, label]) Adds an array before self along an axis.
LArray.append(axis, value[, label]) Adds an array to self along an axis.
LArray.extend(axis, other) Adds an array to self along an axis.
LArray.insert(value[, before, after, pos, …]) Inserts value in array along an axis.
LArray.broadcast_with(target) Returns an array that is (NumPy) broadcastable with target.
LArray.align(other[, join, fill_value, axes]) Align two arrays on their axes with the specified join method.

Testing/Searching

LArray.nonzero() Returns the indices of the elements that are non-zero.
LArray.all(*axes_and_groups[, out, skipna, …]) Test whether all selected elements evaluate to True.
LArray.all_by(*axes_and_groups[, out, …]) Test whether all selected elements evaluate to True.
LArray.any(*axes_and_groups[, out, skipna, …]) Test whether any selected elements evaluate to True.
LArray.any_by(*axes_and_groups[, out, …]) Test whether any selected elements evaluate to True.
LArray.min(*axes_and_groups[, out, skipna, …]) Get minimum of array elements along given axes/groups.
LArray.min_by(*axes_and_groups[, out, …]) Get minimum of array elements for the given axes/groups.
LArray.max(*axes_and_groups[, out, skipna, …]) Get maximum of array elements along given axes/groups.
LArray.max_by(*axes_and_groups[, out, …]) Get maximum of array elements for the given axes/groups.
LArray.labelofmin([axis]) Returns labels of the minimum values along a given axis.
LArray.indexofmin([axis]) Returns indices of the minimum values along a given axis.
LArray.labelofmax([axis]) Returns labels of the maximum values along a given axis.
LArray.indexofmax([axis]) Returns indices of the maximum values along a given axis.

Operators

@ Matrix multiplication

Miscellaneous

LArray.ratio(*axes) Returns an array with all values divided by the sum of values along given axes.
LArray.rationot0(*axes) Returns a LArray with values array / array.sum(axes) where the sum is not 0, 0 otherwise.
LArray.divnot0(other) Divides array by other, but returns 0.0 where other is 0.
LArray.clip(a_min, a_max[, out]) Clip (limit) the values in an array.
LArray.shift(axis[, n]) Shifts the cells of the array n-times to the left along axis.
LArray.diff([axis, d, n, label]) Calculates the n-th order discrete difference along a given axis.
LArray.to_clipboard(*args, **kwargs) Sends the content of the array to clipboard.
round(*args, **kwargs) Round an array to the given number of decimals.
floor(x, /[, out, where, casting, order, …]) Return the floor of the input, element-wise.
ceil(x, /[, out, where, casting, order, …]) Return the ceiling of the input, element-wise.
trunc(x, /[, out, where, casting, order, …]) Return the truncated value of the input, element-wise.
sqrt(x, /[, out, where, casting, order, …]) Return the positive square-root of an array, element-wise.
absolute(x, /[, out, where, casting, order, …]) Calculate the absolute value element-wise.
fabs(x, /[, out, where, casting, order, …]) Compute the absolute values element-wise.
where(condition, [x, y]) Return elements, either from x or y, depending on condition.
isnan(x, /[, out, where, casting, order, …]) Test element-wise for NaN and return result as a boolean array.
isinf(x, /[, out, where, casting, order, …]) Test element-wise for positive or negative infinity.
nan_to_num(*args, **kwargs) Replace nan with zero and inf with finite numbers.

Converting to Pandas objects

LArray.to_series([dropna]) Converts LArray into Pandas Series.
LArray.to_frame([fold_last_axis_name, dropna]) Converts LArray into Pandas DataFrame.

Plotting

LArray.plot Plots the data of the array into a graph (window pop-up).

Input/Output

Read

read_csv(filepath_or_buffer[, nb_index, …]) Reads csv file and returns an array with the contents.
read_tsv(filepath_or_buffer, **kwargs)
read_excel(filepath[, sheetname, nb_index, …]) Reads excel file from sheet name and returns an LArray with the contents
read_hdf(filepath_or_buffer, key[, …]) Reads an array named key from a HDF5 file in filepath (path+name)
read_eurostat(filepath_or_buffer, **kwargs) Reads EUROSTAT TSV (tab-separated) file into an array.
read_sas(filepath[, nb_index, index_col, …]) Reads sas file and returns an LArray with the contents nb_index: number of leading index columns (e.g.

Write

LArray.to_csv(filepath[, sep, na_rep, …]) Writes array to a csv file.
LArray.to_excel([filepath, sheet_name, …]) Writes array in the specified sheet of specified excel workbook.
LArray.to_hdf(filepath, key, *args, **kwargs) Writes array to a HDF file.

Excel

open_excel([filepath, overwrite_file, …]) Open an Excel workbook

Miscellaneous

aslarray(a) Converts input as LArray if possible.
from_frame(df[, sort_rows, sort_columns, …]) Converts Pandas DataFrame into LArray.
labels_array(axes[, title]) Returns an array with specified axes and the combination of corresponding labels as values.
larray_equal(a1, a2) Compares two arrays and returns True if they have the same axes and elements (and do not contain nan values, see note below), False otherwise.
larray_nan_equal(a1, a2) Compares two arrays and returns True if they have the same axes and elements, False otherwise.
nan_equal(a1, a2) Compares two arrays element-wise and returns array of booleans.
union(*args) Returns the union of several “value strings” as a list.
stack([elements, axis, title]) Combines several arrays or sessions along an axis.
identity(axis)
diag(a[, k, axes, ndim, split]) Extracts a diagonal or construct a diagonal array.
eye(rows[, columns, k, title, dtype]) Returns a 2-D array with ones on the diagonal and zeros elsewhere.
ipfp(target_sums[, a, axes, maxiter, …]) Apply Iterative Proportional Fitting Procedure (also known as bi-proportional fitting in statistics, RAS algorithm in economics) to array a, with target_sums as targets.

Session

Session(*args, **kwargs) Groups several array objects together.
arrays([depth]) Returns a session containing all available arrays (whether they are defined in local or global variables) sorted in alphabetical order.
local_arrays([depth]) Returns a session containing all local arrays sorted in alphabetical order.
global_arrays([depth]) Returns a session containing all global arrays sorted in alphabetical order.
load_example_data(name) Load arrays used in the tutorial so that all examples in it can be reproduced.

Exploring

Session.names Returns the list of names of the array objects in the session.
Session.keys() Returns a view on the session’s keys.
Session.values() Returns a view on the session’s values.
Session.items() Returns a view of the session’s items ((key, value) pairs).
Session.summary([template]) Returns a summary of the content of the session.

Copying

Session.copy() Returns a copy of the session.

Selecting

Session.get(key[, default]) Returns the array object corresponding to the key.

Modifying

Session.add(*args, **kwargs) Adds objects to the current session.
Session.get(key[, default]) Returns the array object corresponding to the key.
Session.apply(func, *args, **kwargs) Apply function func on elements of the session and return a new session.
Session.transpose(*args) Reorder axes of arrays in session, ignoring missing axes for each array.

Filtering/Cleaning

Session.filter([pattern, kind]) Returns a new session with array objects which match some criteria.
Session.compact([display]) Detects and removes “useless” axes (ie axes for which values are constant over the whole axis) for all array

Load/Save

Session.load(fname[, names, engine, display]) Loads array objects from a file, or several .csv files.
Session.save(fname[, names, engine, …]) Dumps all array objects from the current session to a file.
Session.to_csv(fname[, names, display]) Dumps all array objects from the current session to CSV files.
Session.to_excel(fname[, names, overwrite, …]) Dumps all array objects from the current session to an Excel file.
Session.to_hdf(fname[, names, overwrite, …]) Dumps all array objects from the current session to an HDF file.
Session.to_pickle(fname[, names, overwrite, …]) Dumps all array objects from the current session to a file using pickle.

Editor

view([obj, title, depth]) Opens a new viewer window.
edit([obj, title, minvalue, maxvalue, …]) Opens a new editor window.
compare(*args, **kwargs) Opens a new comparator window, comparing arrays or sessions.