A blog for computer science passionates.

Tuesday 22 October 2019

How to start ML & DL? NumPy Module Part - 2.2

Hello Friends!!!
In this article, we are going to discuss NumPy objects. In the previous article, we learned about NumPy and how to install NumPy? Now, Let's start with the NumPy module.

The main objective of the NumPy module is a homogeneous multidimensional array. All elements are of the same type, array indexed by a tuple of non - negative integer. In NumPy dimensions are called axes.

There is a class ndarray in NumPy. It works as an alias array.

The NumPy array is not the same as Python array, as python array only works with one - dimensional array.

Let's start with some attributes of ndarray object.

ndarray.ndim - it represents the number of axes of an array (here, axes is the dimension of array).
ndarray.shape - it also represents the dimension of array, but it shows tuple of integers which indicate size of different dimensions. For example (rows, cols) here, rows mean the first dimension of array and cols mean the second dimension of the array. But shape and ndim both are different attribute shape represents tuple and the length of tuple is represented by axes i.e. ndim.
ndarray.size - it represents the total number of elements of array.
ndarray.dtype - it represents the data type of elements in the array.
ndarray.itemsize - it represents the size in bytes of each element of an array.
ndarray.data - it represents the buffer containing actual elements of an array. we need not to use this attribute.

Example:


So, These are some important attributes in NumPy.

In the next article, we will learn about different methods of NumPy. All the best....👍

No comments:

Post a Comment