NumPy Array Shape and Getting Flattened Array Using revel() function

Author: Al-mamun Sarkar Date: 2020-03-31 18:04:00

NumPy Array Shape and Getting Flattened Array Using revel() function. The following shows how to get the shape of an array and make the array flattened using the revel() function of the Python NumPy module. 

 

import numpy as np

 

Code:

a = np.floor(10*np.random.random((3,4)))
a

Output:

array([[ 9.,  9.,  6.,  5.],
       [ 5.,  5.,  3.,  5.],
       [ 3.,  0.,  1.,  2.]])

 

Code:

a.shape

Output:

(3, 4)

 

Code:

a.ravel()

Output:

array([ 9.,  9.,  6.,  5.,  5.,  5.,  3.,  5.,  3.,  0.,  1.,  2.])