numpy的最小值(行,列)格式 [英] Numpy minimum in (row, column) format

查看:1836
本文介绍了numpy的最小值(行,列)格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎么能知道一个最小的数组numpy的/矩阵的(行,列)索引?

How can I know the (row, column) index of the minimum of a numpy array/matrix?

例如,如果 A =阵列([1,2],[3,0]]),我想获得( 1,1)

For example, if A = array([[1, 2], [3, 0]]), I want to get (1, 1)

谢谢!

推荐答案

使用<一个href=\"http://docs.scipy.org/doc/numpy/reference/generated/numpy.unravel_index.html\"><$c$c>unravel_index:

numpy.unravel_index(A.argmin(), A.shape)

这篇关于numpy的最小值(行,列)格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆