I have a 40000 by 60 Numpy array, and I want to sth like this:
mat[:,[0:13,19:23,23:31,39:59]]
Obviously, it does not work. Is there a smarter way to do this than concatenation?
Use np.r_ -
np.r_
mat[:,np.r_[0:13,19:23,23:31,39:59]]
Sample run -
In [48]: mat = np.random.rand(100,1000) In [50]: mat[:,np.r_[0:13,19:23,23:31,39:59]].shape Out[50]: (100, 45) In [51]: 13+4+8+20 Out[51]: 45
2.1m questions
2.1m answers
60 comments
57.0k users