0% found this document useful (0 votes)
60 views

Python Library

The document discusses several popular Python libraries for scientific computing and data analysis including NumPy for numerical computing, Pandas for data structures and analysis, Matplotlib for visualization, SciPy for scientific functions, SymPy for symbolic mathematics, and Numba and NumExpr for accelerating numerical Python code. These libraries provide functionality like N-dimensional arrays, linear algebra, Fourier transforms, data structures, plotting, symbolic algebra, and optimizing Python for performance. The libraries extend Python's capabilities for technical computing, data science, and scientific domains.

Uploaded by

Aakansha Saxena
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
60 views

Python Library

The document discusses several popular Python libraries for scientific computing and data analysis including NumPy for numerical computing, Pandas for data structures and analysis, Matplotlib for visualization, SciPy for scientific functions, SymPy for symbolic mathematics, and Numba and NumExpr for accelerating numerical Python code. These libraries provide functionality like N-dimensional arrays, linear algebra, Fourier transforms, data structures, plotting, symbolic algebra, and optimizing Python for performance. The libraries extend Python's capabilities for technical computing, data science, and scientific domains.

Uploaded by

Aakansha Saxena
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 16

Python-Libraries

Aakansha Saxena
Assistant Professor
Rashtriya Raksha University
Python Libraries -1) Numpy
•  NumPy library to replace the Numeric and NumArray libraries. NumPy
was created based on the Numeric code. The Numeric code was rewritten
to be easier to maintain, and new features could be added to the library.
NumArray features have been added to NumPy.
Purpose of the NumPy library
• Mathematical algorithms implemented in interpreted languages, for
example, Python, often work much slower than the same algorithms
implemented in compiled languages (for example, Fortran, C, and Java).
The NumPy library provides implementations of computational algorithms
in the form of functions and operators, optimized for working with
multidimensional arrays. As a result, any algorithm that can be expressed
as a sequence of operations on arrays (matrices) and implemented using
NumPy works as fast as the equivalent code executed in MATLAB
Features of Numpy:
• A powerful N-dimensional array object
• Sophisticated (broadcasting) functions
• Tools for integrating C/C++ and Fortran code
• Useful linear algebra, Fourier transform, and random number
capabilities
NumPy User Features

• Numpy provides the following features to the user:


• Array objects
• Constants
• Universal functions (ufunc)
• Routine
• Packaging (numpy.distutils)
• NumPy Distutils - Users Guide
• NumPy C-API
• NumPy internals
• NumPy and SWIG
2) Numba
• Numba makes Python code fast
• Numba is an open source JIT compiler that translates a subset of
Python and NumPy code into fast machine code.
1) Accelerate Python Functions
• Numba translates Python functions to optimized machine code at
runtime using the industry-standard LLVM compiler library. Numba-
compiled numerical algorithms in Python can approach the speeds of
C or FORTRAN.
2) Built for Scientific Computing
Numba is designed to be used with NumPy arrays and functions.
Numba generates specialized code for different array data types and
layouts to optimize performance. Special decorators can create 
universal functions that broadcast over NumPy arrays just like NumPy
functions do.
3) Parallelize Your Algorithms
Numba offers a range of options for parallelizing your code for CPUs
and GPUs, often with only minor code changes.
Numba supports Intel and AMD x86, POWER8/9, and ARM CPUs (including Apple
M1), NVIDIA GPUs, Python 3.7-3.10, as well as Windows/macOS/Linux.
Precompiled Numba binaries for most systems are available as conda packages
and pip-installable wheels.
3) NumExpr
NumExpr is a fast numerical expression evaluator for NumPy. With it, expressions that
operate on arrays (like '3*a+4*b') are accelerated and use less memory than doing the
same calculation in Python.

In addition, its multi-threaded capabilities can make use of all your cores -- which
generally results in substantial performance scaling compared to NumPy.

Last but not least, numexpr can make use of Intel's VML (Vector Math Library, normally
integrated in its Math Kernel Library, or MKL). This allows further acceleration of
transcendent expressions.
4) SciPy
• SciPy is a library for the open-source Python programming language, designed to
perform scientific and engineering calculations.
• The capabilities of this library are quite wide:
1. Search for minima and maxima of functions.
2. Calculation of function integrals.
3. Support for special functions.
4. Signal processing.
5. Image processing.
6. Work with genetic algorithms.
7. Solving ordinary differential equations
• SciPy is a collection of mathematical algorithms and functions built as
a Numpy extension in Python. It greatly extends the capabilities of an
interactive Python session by providing the user with high-level
commands and classes for managing and visualizing data. With SciPy,
an interactive Python session becomes a data processing and
prototyping system competing with systems such as MATLAB, IDL,
Octave, R-Lab, and SciLab
SciPy is organized into sub-packages
covering various scientific computing areas:
• cluster - Clustering Algorithms
• constants - physical and mathematical constants
• fftpack - Fast Fourier Transform subroutines
• integrate - integration and solution of ordinary differential equations
• Interpolate - interpolation and smoothing splines
• io - input and output
• linalg - linear algebra
• ndimage - n-dimensional image processing
• odr -orthogonal regression distance multiplexing
• optimize - root structure optimization and search
• signal - signal processing
5) Pandas
• Pandas is an open-source library that is made mainly for working with
relational or labeled data both easily and intuitively. It provides
various data structures and operations for manipulating numerical
data and time series. This library is built on top of the NumPy library.
Pandas is fast and it has high performance & productivity for users.
Advantages
• Fast and efficient for manipulating and analyzing data.
• Data from different file objects can be loaded.
• Easy handling of missing data (represented as NaN) in floating point as well as non-
floating point data
• Size mutability: columns can be inserted and deleted from DataFrame and higher
dimensional objects
• Data set merging and joining.
• Flexible reshaping and pivoting of data sets
• Provides time-series functionality.
• Powerful group by functionality for performing split-apply-combine operations on
data sets
6) SymPy
• SymPy is a Python library for symbolic mathematics. It aims to become a full-featured
computer algebra system (CAS) while keeping the code as simple as possible in order
to be comprehensible and easily extensible. SymPy is written entirely in Python
SymPy is…
• Free: Licensed under BSD, SymPy is free both as in speech and as in beer.
• Python-based: SymPy is written entirely in Python and uses Python for its language.
• Lightweight: SymPy only depends on mpmath, a pure Python library for arbitrary
floating point arithmetic, making it easy to use.
• A library: Beyond use as an interactive tool, SymPy can be embedded in other
applications and extended with custom functions
Projects using SymPy
• Cadabra: Tensor algebra and (quantum) field theory system using SymPy for scalar algebra.
• ChemPy: A package useful for chemistry written in Python.
• EinsteinPy: A Python package for symbolic and numerical General Relativity.
• galgebra: Geometric algebra (previously sympy.galgebra).
• LaTeX Expression project: Easy LaTeX typesetting of algebraic expressions in symbolic form with automatic
substitution and result computation).
• Lcapy: Experimental Python package for teaching linear circuit analysis.
• OctSymPy: A Symbolic Package for Octave using SymPy.
• Optlang: A Python package for solving mathematical optimization problems.
• PyDy: Multibody dynamics in Python.
• pyneqsys: Solve symbolically defined systems of non-linear equations numerically.
• pyodesys: Straightforward numerical integration of ODE systems from Python.
• QMCPACK: Quantum Monte Carlo in C++. Sympy is used to generate reference values for unit tests and
some code generation.
• Quantum Programming in Python: Quantum 1D Simple Harmonic Oscillator and Quantum Mapping Gate.
7)Matplotlib
• Matplotlib is a comprehensive library for creating static, animated,
and interactive visualizations in Python. Matplotlib makes easy things
easy and hard things possible.
• Create publication quality plots.
• Make interactive figures that can zoom, pan, update.
• Customize visual style and layout.
• Export to many file formats.
• Embed in JupyterLab and Graphical User Interfaces.
• Use a rich array of third-party packages built on Matplotlib
Types of graphs and charts
The package supports many types of graphs and charts:
• Charts (line plot)
• Scatter plot
• Bar charts and histograms
• Pie Chart
• Chart trunk (stem plot)
• Contour plots
• Gradient Fields (quiver)
• Spectrograms
• The user can specify the coordinate axis, grid, add labels and explanations, use
a logarithmic scale or polar coordinates

You might also like