What is Numpy? Why Numpy ?

Hello guys! Welcome to my blog. In this article I am going to discuss basic points regarding Numpy. So let’s have a look towards the Numpy. 
Topics covered: 
1 What is NumPy?
2 Why is NumPy is required?
3 Why NumPy is faster than list?
4 How to install NumPy?
5 How to install NumPy?
6 How to import NumPy and how to use?
7 How to check Numpy version?
8 How to create Numpy Nd array object?
9 Dimensions in arrays.



What is NumPy?
• NumPy stands fir numerical-python. It is one of the libraries of python, which is used to work with arrays.
• It is having many functions to work with linear algebra, matrices, Fourier transform. 
• It is an open source, so it is free to use. It has created in 2005, by "travis oliphant”.

Why is NumPy is required?
• In python, there is list datatype which serves the purpose of arrays but they process slowly. 
  Whereas NumPy provides an array object, which is up to 50x faster as compared with python lists.
• In NumPy, array object can be called as Nd array and it provides supporting functions.which make working with Nd array too easy.
Why NumPy is faster than list?

• In lists, arrays are not stored at one continuous place in memory but NumPy arrays will be stored at one continuous place. So that, the process can access and manipulate them in efficient manner. This behaviour can be called as locality of reference in computer science. This is why the NumPy is better than lists. It has optimized to work with the latest CPU architecture. 

• NumPy has written in Python language, but many parts are written in C language or C++, which are required for fast computation.

How to install NumPy?
• If you have installed python and PIP already on your system then we can install NumPy easily by         using this command.
 ** C:\Users\Your Name>pip install NumPy**

• Suppose if this command fails, then we have to use, python distribution which has NumPy installed like, Anaconda, Spyder etc.

How to import NumPy and how to use?

• After installation of NumPy, we have to import it by adding the import keyboard
 *import NumPy*.  
• Now you have imported NumPy and it is ready to use.

   Example-   import numPy
                       a= numpy.array([2,4,6,8,10])
                       Print(a)

How to check Numpy version? 
The Numpy version string will be stored under,
                       __version__attribute 
Example-  import numpy as nump
                   Print(nump.__version__)

How to create Numpy Nd array object? 
• Numpy is mainly used to work with arrays and the array object in numpy is called Nd
  array.
• The Numpy  Nd array object can be created using the array () function.
           Example- import numpy as nump
                             a=nump.array([2,4,6,8,10])
                             Print(a)
                             Print(type(a))


Dimensions in arrays: 

0-D array: 
• 0-D array or scalar is the element in an array. Each and every value in an array is a 0-D array. Let’s     create a 0-D array with value 42.
           import numpy as nump
           a= nump.array(42)
           Print(a)
 
1-D array:  
• The array which has 0-D arrays as elements can be called as unidimensional or 1-D array. 
• 1-D arrays are most common and basic array.
• Let’s create a 0-D array with value 42.
           import numpy as nump
           a= nump.array([2,4,6,8])
           Print(a)

2-D array:  
• The array which has 1-D arrays as elements can be called as unidimensional or 1-D array. 
• 2-D arrays can be used to represent matrix or 2nd order tensors.
• Numpy has a sub module which can be used for matrix operations and it is called
  as NumPy. mat
• Let’s create a 2-D that contains two 1-D array
           import numpy as nump
           a= nump.array( [[2,4,6,8], [10,12,14]] )
           Print(a)

Thank you!! If you want article on any other topic please do suggest us.






Post a Comment

0 Comments