This time to bring you how to take NumPy array to specify the row and column, take numpy array to specify the column of attention to what, the following is the actual case, together to see.
The operation on the NumPy array is a bit cumbersome, but there is no way.
For example
A = [[4,5,6], [[7,8,9]]
Take a of 2 3 rows, 1 2 columns
c=[1,2] D =[0,1]
If written as
b = a[c,d] Output: [4 8]
Take the data from the second row, the first column and the third row.
This is not the result we want.
The correct approach is:
b = a[c] First fetch the desired row data B = b[:,d] Print (b) Output: [[4 5] [7 8]]
This is the result we want. This must take two steps to complete.
Believe that you have read the case of this article you have mastered the method, more exciting please pay attention to the PHP Chinese network other related articles!
Recommended reading:
Perfect solution python2.7 cannot use Pip
Python how to read and write TXT file line-wise