Indexing routines

See also

Indexing

Generating index arrays

c_ Translates slice objects to concatenation along the second axis.
r_ Translates slice objects to concatenation along the first axis.
s_ A nicer way to build up index tuples for arrays.
nonzero (a) Return the indices of the elements that are non-zero.
where (condition, [x, y]) Return elements, either from x or y, depending on condition.
indices (dimensions[, dtype]) Return an array representing the indices of a grid.
ix_ (*args) Construct an open mesh from multiple sequences.
ogrid Construct a multi-dimensional open “meshgrid”.
unravel_index (x, dims) Convert a flat index into an index tuple for an array of given shape.

Indexing-like operations

take (a, indices[, axis, out, mode]) Take elements from an array along an axis.
choose (a, choices[, out, mode]) Use an index array to construct a new array from a set of choices.
compress (condition, a[, axis, out]) Return selected slices of an array along given axis.
diag (v[, k]) Extract a diagonal or construct a diagonal array.
diagonal (a[, offset, axis1, axis2]) Return specified diagonals.
select (condlist, choicelist[, default]) Return an array drawn from elements in choicelist, depending on conditions.

Inserting data into arrays

place (arr, mask, vals) Changes elements of an array based on conditional and input values.
put (a, ind, v[, mode]) Changes specific elements of one array by replacing from another array.
putmask (a, mask, values) Changes elements of an array based on conditional and input values.

Iterating over arrays

ndenumerate Multidimensional index iterator.
ndindex Pass in a sequence of integers corresponding to the number of dimensions in the counter. This iterator will then return an N-dimensional counter.
flatiter