Python Library
Python Library
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
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