To start with this Numpy tutorial, we you need to have the basic idea of python syntax. So, if you don’t have this prerequisite then go for Python tutorial first. Numpy stands for “Numerical Python” which is generally used with matplotlib (visualization library ) and scipy ( Scientific Python ) mainly for data science. Numpy’s main object is the homogeneous multidimensional array. It is a table of elements (usually numbers), all of the same type, indexed by a tuple of positive integers.
Numpy’s array class is called ndarray. It is also known by the alias array. Note that Numpy.array is not the same as the Standard Python Library class array. array, which only handles one-dimensional arrays and offers less functionality.
Numpy’s main object is the homogeneous multidimensional array which is called ndarray.
It is a table of elements (usually numbers), all of the same type, indexed by a tuple of positive integers. In Numpy dimensions are called axes. The number of axes is rank. The rank 1 array is like – [2,3,4], it is similar to a 1-D array in most of the programming languages. If you try to find out the dimensions of this Rank 1, The array then it will return (1,) which is not preferable for training the model. So We try to create this array like – [[1,2,3,]] which will result in better dimensions.
How to create ndarray
import numpy as np
a = np.array([1.,2.,3.]) print(a.shape) b = np.array([[1.,2.,3.]]) print(b.shape)
(3,) (1, 3)
dtype-> It will let you know about the data type of stored values in the array.
type-> It will return the type of object associated with the variable
How to create 2-D or multidimensional array
c = np.array([[1,2] , [3,4]])
[[1 2] [3 4]]