Uttar Pradesh, India
Instagram
image

Quick start with NumPy

NumPy:

"A python package for numerical processing, it is built on the top of python and widely used for Data Science and Machine Learning.NumPy is an abbreviation for "Numeric Python" or "Numerical Python". It is an open source package for Python.

Top advantages over python builtin list :

1-Numerical processing

2-Open source python package

3-In general Numpy processes faster and uses less code compared to default bulitin python lists.

4-They don’t support “vectorized” operations like elementwise addition and multiplication, and the fact that they can contain objects of differing types mean that Python must store type information for every element, and must execute type dispatching code when operating on each element.


5-NumPy is not just more efficient; it is also more convenient. You get a lot of vector and matrix operations for free, which sometimes allow one to avoid unnecessary work. And they are also efficiently implemented.

6-NumPy array is faster and you get a lot built in with NumPy, FFTs, convolutions, fast searching, basic statistics, linear algebra,histograms, etc.

Important functions in NumPy

1-ndarray.ndim

The number of axes (dimensions) of the ndarray.

2-ndarray.shape

The dimensions of the ndarray.This is a tuple of integers indicating the size of the array in each dimension. For a matrix with n rows and m columns, shape will be (n,m). The length of the shape tuple is therefore the number of axes, ndim.


3-ndarray.size

The total number of elements of the array.

4-ndarray.dtype

An object describing the type of the elements in the array.Additionally NumPy provides types of its own. numpy.int32, numpy.int16, and numpy.float64 are some examples.


5-ndarray.itemsize
The size in bytes of each element of the array.

6-ndarray.data
the buffer containing the actual elements of the array. Normally, we won’t need to use this attribute because we will access the elements in an array using indexing facilities.


Sample Code :

import numpy as np

a = np.array([2,3,4])
a
array([2, 3, 4])
a.dtype
dtype('int64')

b = np.array([1.2, 3.5, 5.1])

b.dtype
dtype('float64')

In my upcoming blog post ,I will discuss numpy package in more depth.Click here to access my code.


Comments

Share your thoughts in the comments

Your email address will not be published. Required fields are marked *