Indexing routines#

Generating index arrays#

diag_indices(n[, ndim])

Return the indices to access the main diagonal of an array.

diag_indices_from(arr)

Return the indices to access the main diagonal of an n-dimensional array.

indices(dimensions[, dtype, sparse])

Return an array representing the indices of a grid.

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.

Indexing-like operations#

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])

Extract a diagonal or construct a diagonal array.

diagonal(a[, offset, axis1, axis2])

Return specified diagonals.

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

Take elements from an array along an axis.