Write a NumPy program to create a new shape to an array without changing its data
import numpy as np x = np.array([1, 2, 3, 4, 5, 6]) y = np.reshape(x,(3,2)) print("Reshape 3x2:") print(y) z = np.reshape(x,(2,3)) print("Reshape 2x3:") print(z)
Sample Output:
Reshape 3x2: [[1 2] [3 4] [5 6]] Reshape 2x3: [[1 2 3] [4 5 6]]
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Sample Output:
need an explanation for this answer? contact us directly to get an explanation for this answer