[SciPy-User] NumPy array slicing: take all rows but several columns from the array

Alexander Kalinin alec.kalinin@gmail....
Wed Jul 4 08:37:10 CDT 2012


I am trying to find the best way of slicing NumPy array. I need to extract
all rows but several columns from the array. For example, I want to fill
with 1.0 only 0, 2, 5 columns of the array. But the following code does not

import numpy as np
A = np.zeros((10, 7))
A[:, 0, 2, 5] = 1.0         # does not work

What is the best way to do it?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20120704/abd4df10/attachment.html 

More information about the SciPy-User mailing list