0

I want to know the co

import numpy as np
a = np.array([[0,0,0,2,3,0],[3,2,4,0,0,1]])

If I want to get col2 to col4, so result may be:

[[0,2,3][4,0,0]]

How can I make it? Thanks.

2
  • I think that here there is almost all you need about numpy slicing Commented Aug 7, 2013 at 9:57
  • Besides: your title and your question don't match. Fix either one or the other Commented Aug 7, 2013 at 9:58

1 Answer 1

1
>>> import numpy as np
>>> a = np.array([[0,0,0,2,3,0],[3,2,4,0,0,1]])
>>> a[:,2:5]
array([[0, 2, 3],
       [4, 0, 0]])
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.