문제

I have a 2D array to represent a many-many mapping :

0   3   1   3
3   0   0   0
1   0   0   0
3   0   0   0

What is the quickest way to 'zero' out rows and column entries corresponding to a particular index in this array?

도움이 되었습니까?

해결책

arr[i] = 0   # zeroes out row i
arr[:,i] = 0 # zeroes out column i
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top