NumPy
DR. ARCHANA RAJE
What is NumPy?
➢ NumPy is a Python library used for working with arrays.
➢ NumPy was created in 2005 by Travis Oliphant.
➢ NumPy is short for "Numerical Python".
➢ NumPy aims to provide an array object that is up to 50x faster than traditional
Python lists.
➢ NumPy arrays are stored at one continuous place in memory unlike lists, so
processes can access and manipulate them very efficiently.
➢ NumPy is an open-source Python library consisting of multidimensional and
single-dimensional array elements.
Why NumPy - Need of NumPy
➢ NumPy includes a wide range of mathematical functions for basic arithmetic, linear
algebra, Fourier analysis, and more.
➢ NumPy performs numerical operations on large datasets efficiently.
➢ NumPy supports multi-dimensional arrays, allowing for the representation of complex
data structures such as images, sound waves, and tensors in machine learning models.
➢ It supports the writing of concise and readable code for complex mathematical
computations.
➢ NumPy integrates with other libraries to do scientific computation; these are SciPy
(for scientific computing), Pandas (for data manipulation and analysis), and scikit-learn
(for machine learning).
➢ Many scientific and numerical computing libraries and tools are built on top of NumPy.
➢ Its widespread adoption and stability make it a standard choice for numerical
computing tasks.
NumPy Applications - Uses of NumPy
The NumPy API in Python is used primarily for numerical computing. It provides support
for a wide range of mathematical functions to operate on data efficiently.
The following are some common application areas where NumPy is extensively used:
➢Data Analysis: NumPy offers rapid and effective array operations, rendering it well-
suited for tasks like data cleansing, filtering, and transformation. It is predominantly
used in the analysis and scientific handling of data, particularly when working with
extensive, large datasets.
➢Machine Learning and Artificial Intelligence: Different machine learning and deep
learning frameworks in Python, such as TensorFlow, and PyTorch, rely on NumPy arrays
for handling input data, model parameters, and outputs.
➢Scientific Computing: NumPy is widely used in scientific computing applications such
as physics, chemistry, biology, and astronomy for data manipulation, numerical
simulations, and analysis.
➢Array manipulation: NumPy provides an assortment of methods for manipulating
arrays, such as resizing, slicing, indexing, stacking, splitting, and concatenating arrays.
NumPy Applications - Uses of NumPy
➢Finance and Economics: The NumP API is also widely used in financial data
analysis and economics to do portfolio optimisation, risk analysis, time series
analysis, and statistical modelling.
➢Engineering and Robotics: NumPy is used in engineering disciplines such as
mechanical, civil, and electrical engineering for tasks like finite element
analysis, control system design, and robotics simulations.
➢Image and Signal Processing: NumPy is extensively used in processing and
analysing images and signals.
➢Data Visualization: NumPy doesn't provide data visualisation but supports
Matplotlib and Seaborn libraries to generate plots and visualisations from
numerical data.
NumPy as np
NumPy is usually imported under the np alias.
Example:
import numpy as np
arr = [Link]([1, 2, 3, 4, 5])
Print(arr)
Print(type(arr))
type(): This built-in Python function tells us the type of the object
passed to it. Like in above code it shows that arr is [Link]
type.