python - How to return some column items in a numpy array? -


i want print items in 2d numpy array, example:

a = [[1, 2, 3, 4],      [5, 6, 7, 8]]  = numpy.array(a) 

how can return (1 , 2) also, (5, , 6), , how can keep dimension [2,2]??

the following:

a[:, [0, 1]] 

will select first 2 columns (with index 0 , 1). result be:

array([[1, 2],        [5, 6]]) 

Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -