How to Create a NumPy Array with a Specified Dimension


In this example we will show how to create a NumPy array with a specified dimension use the ndmin argument in Python.

Source Code

import numpy as np

n = np.array([1, 2, 3, 4, 5], ndmin=6)

print(n)
print('The dimension of the array is:', n.ndim)

Output:

[[[[[[1 2 3 4 5]]]]]]
The dimension of the array is: 6
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments