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

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -