Q:

Write a NumPy program to collapse a 3-D array into one dimension array

0

Write a NumPy program to collapse a 3-D array into one dimension 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.eye(3)
print("3-D array:")
print(x)
f = np.ravel(x, order='F')
print("One dimension array:")
print(f)

Sample Output:

3-D array:                                                             
[[ 1.  0.  0.]                                                         
 [ 0.  1.  0.]                                                         
 [ 0.  0.  1.]]                                                        
One dimension array:                                                   
[ 1.  0.  0.  0.  1.  0.  0.  0.  1.]

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