[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


Hello,

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
work:

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?

Sincerely,
Alexander
-------------- 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