Q:

Write a NumPy program to create a contiguous flattened array

0

Write a NumPy program to create a contiguous flattened array.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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]

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now