Name

reshape

Synopsis

reshape(a,shapetuple)

Returns an array r with shape shapetuple, sharing a’s data. r =reshape( a,shapetuple ) is just like r = a ; r .shape= shapetuple. The product of shapetuple’s items must equal the product of a .shape’s, but one of shapetuple’s items may be -1 to ask for adaptation of that axis’s length. For example:

print Numeric.reshape(range(12),(3,-1))     
# prints: [[0 1 2 3]
#          [4 5 6 7]
#          [8 9 10 11]]

Get Python in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.