문제

I have a 2D numpy array A (MxN) and want to select a range of columns, lets say from m to n, (or rows - does not matter) like this:

A = A[m-n,:]

Is there a way to simply achieve this?

도움이 되었습니까?

해결책

You can do it as:

B = A[m:n,:]

or if you want to include the n-th row:

B = A[m:n+1,:]

Similarly for columns:

C = A[:,m:n]

or

C = A[:,m:n+1]
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top