Guided Notes
Reshape, Join & Split
Changing an array's shape, flattening, joining arrays with concatenate and stack, and splitting them.
Reshaping
Slide 1 / 5reshape() rearranges the same elements into a new shape:
arr = np.arange(1, 13) # 12 elements arr.reshape(4, 3) # 4 rows Γ 3 columns arr.reshape(2, 3, 2) # 3-D
The total number of elements must stay the same: 12 elements fit 4Γ3, 2Γ6, or 2Γ3Γ2, but not 5Γ3.
reshape usually returns a view of the original data, so it's fast even for huge arrays.
