[SciPy-User] NumPy array slicing: take all rows but several columns from the array
Alexander Kalinin
alec.kalinin@gmail....
Wed Jul 4 08:46:55 CDT 2012
I found an error. I need to use a tuple of indexes. The following code did
what I want:
import numpy as np
A = np.zeros((10, 7))
A[:, (0, 2, 5)] = 1.0
Alexander.
On Wed, Jul 4, 2012 at 5:37 PM, Alexander Kalinin <alec.kalinin@gmail.com>wrote:
> 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/fe34e635/attachment.html
More information about the SciPy-User
mailing list