Write a NumPy program to create a contiguous flattened array.
import numpy as np x = np.array([[10, 20, 30], [20, 40, 50]]) print("Original array:") print(x) y = np.ravel(x) print("New flattened array:") print(y)
Sample Output:
Original array: [[10 20 30] [20 40 50]] New flattened array: [10 20 30 20 40 50]
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