Numpy Ndarray

2019-08-19 Omsingh Bais

Numpy Ndarray


Ndarray is The n-dimensional array object defined in the numpy is ndarray which stores the collection of the similar type of elements. 

An item in an ndarray takes the same size of block in the memory. The ndarray object can be accessed by using the 0 based indexing.

Creating a ndarray :

x = numpy.array

Before creating the ndarraay make sure that the numpy module is installed and imported into the program. If not install then check this article (Installation-of-numpy).

import numpy as np
x =  np.array()

The above code will create the empty  n-dimensional array. We can also pass the parameters in the array  to create the equivalent n-dimensional array, Use following syntax.

numpy.array(object, dtype = None, copy = True, order = None, subok = False, ndmin = 0)  

Following are the in-details use of parameters.

Sr No. Parameter Description
1 object  It represents the object. It can be a list, dictionary, set, tuple etc.
2 dtype  The dtype parameter is used for changing data type. e.g float, int,     complex etc
3 copy  By default it is true and optional. Which means the object is copied.
4 order  Order can be C (column), R (row), or A (any)(default)
5 subok  It returned base class array by default. We can change it option to true so   it will passes through subclasses.
6 ndmin  Ndmin means minimum dimensions of the resulting array.


Following are the some example to creating ndarray.

  • creating array using list
import numpy as np 
x = np.array([11,25,48]) 
print (x)

Output :

[11, 25, 48]


For in-depth opertaion of ndarray check this article ( Numpy-Ndarray-Operation)


Happy coding....


  • Please give your suggestion if you find anything incorrect. Contact us at

About author

Card image cap
Omsingh Bais

Having more than 1+ year experience in the data scientist domain.!

-Data Scientist