Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

how to access rows and columns indexing numpy

>>> a[[0,1,3], :]            # Returns the rows you want
array([[ 0,  1,  2,  3],
       [ 4,  5,  6,  7],
       [12, 13, 14, 15]])
>>> a[[0,1,3], :][:, [0,2]]  # Selects the columns you want as well
array([[ 0,  2],
       [ 4,  6],
       [12, 14]])
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #access #rows #columns #indexing #numpy
ADD COMMENT
Topic
Name
6+4 =