[Numpy-discussion] rollaxis and reshape

Elfnor elfnor@gmail....
Wed Dec 10 14:54:13 CST 2008


I'm trying to split an array into two pieces and have the two pieces in a
new dimension.

Here it is in code, because that's hard to explain in words.

(4, 50, 3)
>>>new_data = numpy.zeros((2, 4, 25, 3))
>>>new_data[0,...] = data[:,:25,:]
>>>new_data[1,...] = data[:,25:,:]
(2, 4, 25, 3)

That works but when I try it with reshape the elements get in the wrong
place. I've tried various combinations of rollaxis before the reshape, but
can't get it right.

Thanks Eleanor

View this message in context: http://www.nabble.com/rollaxis-and-reshape-tp20943690p20943690.html
Sent from the Numpy-discussion mailing list archive at Nabble.com.

More information about the Numpy-discussion mailing list