[SciPy-User] Reshaping Question
Skipper Seabold
jsseabold@gmail....
Wed Nov 4 19:25:12 CST 2009
My brain is failing me. Is there a clean way to reshape an array like
the following?
import numpy as np
c = np.arange(16).reshape(4, 2, 2)
In [209]: c
Out[209]:
array([[[ 0, 1],
[ 2, 3]],
[[ 4, 5],
[ 6, 7]],
[[ 8, 9],
[10, 11]],
[[12, 13],
[14, 15]]])
So that c == d where
d = np.array(([0, 1, 4, 5], [2,3,6,7], [8,9,12,13], [10, 11, 14, 15]))
In [211]: d
Out[211]:
array([[ 0, 1, 4, 5],
[ 2, 3, 6, 7],
[ 8, 9, 12, 13],
[10, 11, 14, 15]])
Cheers,
Skipper
More information about the SciPy-User
mailing list