numpy.unravel_index()函数将平面索引或平面索引数组转换为坐标数组的元组。
用法: numpy.unravel_index(indices, shape, order = ‘C’)
参数:
indices :[array_like] An integer array whose elements are indices into the flattened version of an array of dimensions shape.
shape :[tuple of ints] The shape of the array to use for unraveling indices.
order :[{‘C’, ‘F’}, optional] Determines whether the multi-index should be viewed as indexing in row-major (C-style) or column-major (Fortran-style) order.
返回:[ndarray的元组]元组中的每个数组都具有与indexs数组相同的形状。
代码1:
# Python program explaining
# numpy.unravel_index() function
# importing numpy as geek
import numpy as geek
gfg = geek.unravel_index([22, 41, 37], (7, 6))
print(gfg)
输出:
(array([3, 6, 6]), array([4, 5, 1]))
代码2:
# Python program explaining
# numpy.unravel_index() function
# importing numpy as geek
import numpy as geek
gfg = geek.unravel_index([22, 41, 37], (7, 6), order = 'F')
print(gfg)
输出:
(array([1, 6, 2]), array([3, 5, 5]))
相关用法
- Python Wand function()用法及代码示例
- Python sum()用法及代码示例
- Python hex()用法及代码示例
- Python tell()用法及代码示例
- Python dir()用法及代码示例
- Python id()用法及代码示例
- Python map()用法及代码示例
- Python int()用法及代码示例
- Python cmp()用法及代码示例
- Python ord()用法及代码示例
- Python now()用法及代码示例
- Python oct()用法及代码示例
- Python str()用法及代码示例
- Python range()用法及代码示例
- Python math.gcd()用法及代码示例
- Python turtle.pen()用法及代码示例
注:本文由纯净天空筛选整理自sanjoy_62大神的英文原创作品 numpy.unravel_index() function | Python。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。