numpy.unravel_index()

numpy.unravel_index

numpy.unravel_index(indices, dims, order='C')

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

Parameters:

indices : array_like

An integer array whose elements are indices into the flattened version of an array of dimensions dims. Before version 1.6.0, this function accepted just one index value.

dims : tuple of ints

The shape of the array to use for unraveling indices.

order : {‘C’, ‘F’}, optional

Determines whether the indices should be viewed as indexing in row-major (C-style) or column-major (