NumPy参考 >例行程序 >Indexing routines > numpy.unravel_index
numpy.
unravel_index
(index,shape,order ='C' )¶将平面索引或平面索引数组转换为坐标数组的元组。
一个整数数组,其元素是维度数组的扁平化版本的索引shape
。在1.6.0版之前,此函数仅接受一个索引值。
用于展开的数组的形状indices
。
在1.16.0版中进行了更改:从更改dims
为shape
。
确定是将索引视为按行为主(C样式)还是按列为主(Fortran样式)的索引。
1.6.0版中的新功能。
元组中的每个数组都具有与indices
数组相同的形状。
也可以看看
例子
>>> np.unravel_index([22, 41, 37], (7,6))
(array([3, 6, 6]), array([4, 5, 1]))
>>> np.unravel_index([31, 41, 13], (7,6), order='F')
(array([3, 6, 6]), array([4, 5, 1]))
>>> np.unravel_index(1621, (6,7,8,9))
(3, 1, 4, 1)