What is NumPy in Python Library

NumPy stands for "Numerical Python" is a Python library that adds powerful and very efficient "Data structure" to Python called as n-dimensional arrays. It has a fixed size and contains the same data types in the array. NumPy offers a rich set of functions for performing fast operations on arrays, including mathematical, logical, shape manipulation, sorting, basic linear algebra, basic statistical operations, and much more. It is at the core of the Python data ecosystem, used in almost every field of science and engineering. That's why it has become a fundamental package for scientific and mathematical computation.


Note: NumPy is a Python library that is written in partially Python and high-performance languages like C and C++ for faster computation, primarily using C or C++.

You can check out their source code at GitHub repository https://github.com/numpy/numpy

The NumPy API is extensively used in Pandas, SciPy, Matplotlib, scikit-learn, scikit-image, and many other data science and scientific Python packages.

Differences between NumPy arrays and Python list:

  • NumPy arrays have a fixed size during their creation, while in Python lists list can grow dynamically. if you Change the size of a ndarray, it will create a new array and delete the original array.


  • The elements in a NumPy array are all required to be of the same data type, and thus will be the same size in memory. The exception: one can have arrays of (Python, including NumPy) objects, thereby allowing for arrays of different-sized elements.


  • NumPy arrays facilitate advanced mathematical and other types of operations on large numbers of data. Typically, such operations are executed more efficiently and with less code than is possible using Python’s built-in sequences.  


  • A growing plethora of scientific and mathematical Python-based packages are using NumPy arrays; though these typically support Python-sequence input, they convert such input to NumPy arrays prior to processing, and they often output NumPy arrays. In other words, in order to efficiently use much (perhaps even most) of today’s scientific/mathematical Python-based software, just knowing how to use Python’s built-in sequence types is insufficient - one also needs to know how to use NumPy arrays.


Post a Comment

Previous Post Next Post