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に非常に慣れていないので、最もPython的な方法で次のことを達成しようとしています。したがって、2つの配列があります。
a=array([[0, 1, 2],[3,4,5]]) b=zeros(a.shape)
さて、私が望むのは、bの各要素について、aの対応する要素の値よりも1つ大きいことです。つまり、b = a + 1
どうすればこれをnumpyで実現できるのだろうと思っていました。
最も簡単な方法は次のとおりです。
b = a + 1
ただし、自分で配列を反復処理する場合(推奨されませんが):
for i in range(len(a)): for j in range(len(a[i])): b[i][j] = a[i][j] + 1