flatten, ravel and T
flatten copies to 1D, ravel returns a view when possible and T transposes.
Example
a = np.arange(6).reshape(2, 3)
print(a.flatten())
print(a.T.shape)
print(a.ravel().tolist())Result
[0 1 2 3 4 5] (3, 2) [0, 1, 2, 3, 4, 5]
Exercise
Transpose.
a.Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.