[Numpy-discussion] Slice and assign into new NDarray...
Sat Mar 8 18:19:17 CST 2008
* This may be a dupe as gmail hotkeys sent a draft prematurely...
After scouring material and books I remain stumped with this one as a
new Numpy user-
I have an ND array with shape (10,15) and want to slice or subset(?) the data
into a new 2D array with the following criteria:
1) Separate each 5 observations along axis=0 (row) and transpose them to
the new array with shape (50,3)
Col1 Co2 Col3
Slice1 Slice2 Slice3
Slice1 should have the coordinates[0:5,0], Slice2[0:5,1] and so
on...I've tried initializing the target ND array with
D = NP.zeros((50,3), dtype='int') and then assigning into it with
for s in xrange(original_array.shape):
D= NP.transpose([data[s,i:i+step] for i in range(0,data.shape, step)])
with step = 5 but I get errors i.e. IndexError: invalid index
Also tried various combos of explicitly referencing D coordinates but
to no avail.
More information about the Numpy-discussion