Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
numpy配列/行列の最小値の(行、列)インデックスを知るにはどうすればよいですか?
たとえばA = array([[1, 2], [3, 0]])、(1, 1)
A = array([[1, 2], [3, 0]])
(1, 1)
ありがとう!
使用unravel_index:
unravel_index
numpy.unravel_index(A.argmin(), A.shape)
[タイプミスを修正]
別の簡単な解決策は
ri, ci = A.argmin()//A.shape[1], A.argmin()%A.shape[1]
numpy.argminは、行の主要な順序でインデックスの読み取り値を返すため
はい、あなたは正しいです、それは正方行列のために働いたタイプミスでした