WeCodeAcademy

Shape, Type and Reshape

Every array has a shape (size of each dimension), ndim, size and a dtype (the type of its numbers). reshape rearranges the same numbers into a new shape, as long as the total count stays the same. Use -1 to let NumPy work out one dimension.

Examplepython
Open in editor »
Quick check

Which reshape of a 12-element array is NOT possible?

Your turn: write the code

Reshape np.arange(12) into 3 rows and 4 columns and print its shape.

Finish the quick check (and any code exercise) to complete this lesson, or mark it done yourself.

Tip: use the left and right arrow keys to move between lessons.