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
Post a Comment