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

Martin Helm martin at mhelm.de
Wed Jul 4 09:44:41 EDT 2012


Am 04.07.2012 15:37, schrieb Alexander Kalinin:
> import numpy as np
> A = np.zeros((10, 7))
> A[:, 0, 2, 5] = 1.0         # does not work
Use
A[:, [0, 2, 5]] = 1.0
as you do it you index a 4 dimensional array




More information about the SciPy-User mailing list