Indexing routines#

See also

basics.indexing

Generating index arrays#

c_

Translates slice objects to concatenation along the second axis.

r_

Translates slice objects to concatenation along the first axis.

nonzero(a)

Return the indices of the elements that are non-zero.

where(condition, [x, y], /)

Return elements chosen from x or y depending on condition.

indices(dimensions[, dtype, chunk_size])

Return an array representing the indices of a grid.

ogrid

nd_grid instance which returns an open multi-dimensional "meshgrid".

unravel_index(indices, shape[, order])

Converts a flat index or array of flat indices into a tuple of coordinate arrays.

Indexing-like operations#

take(a, indices[, axis, out])

Take elements from an array along an axis.

choose(a, choices[, out, mode])

Construct an array from an index array and a list of arrays to choose from.

compress(condition, a[, axis, out])

Return selected slices of an array along given axis.

diag(v[, k, sparse, gpu, chunk_size])

Extract a diagonal or construct a diagonal array.

select

This module supports asynchronous I/O on multiple file descriptors.

Inserting data into arrays#

fill_diagonal(a, val[, wrap])

Fill the main diagonal of the given array of any dimensionality.

Iterating over arrays#

ndindex(*shape)

An N-dimensional iterator object to index arrays.