SlideShare a Scribd company logo
What is NumPy?
NumPy stands for Numerical Python.
NumPy is a Python library used for working with arrays.
It also has functions for working in domain of linear algebra, fourier transform, and
matrices.
NumPy was created in 2005 by Travis Oliphant. It is an open source project and you
can use it freely.
NumPy is a general-purpose array-processing package. It provides a high-
performance multidimensional array object and tools for working with these arrays. It
is the fundamental package for scientific computing with Python.
Why Use NumPy?
•In Python we have lists that serve the purpose of arrays, but they are slow to
process.
•NumPy aims to provide an array object that is up to 50x faster than traditional
Python lists.
•The array object in NumPy is called ndarray, it provides a lot of supporting functions
that make working with ndarray very easy.
•Arrays are very frequently used in data science, where speed and resources are very
important.
•It is capable of performing Fourier Transform and reshaping the data stored in
multidimensional arrays.
•NumPy provides the in-built functions for linear algebra and random number
generation.
Why is NumPy Faster Than Lists?
NumPy arrays are stored at one continuous place in memory unlike lists, so processes
can access and manipulate them very efficiently. This behavior is called locality of
reference in computer science.This is the main reason why NumPy is faster than lists.
Also it is optimized to work with latest CPU architectures.
NumPy – Environment setup
Standard Python distribution doesn't come bundled with NumPy module. A
lightweight alternative is to install NumPy using popular Python package installer, pip.
pip install numpy.
NumPy as np
NumPy is usually imported under the np alias.
alias: In Python alias are an alternate name for referring to the same thing.
Create an alias with the as keyword while importing:
Checking NumPy Version
The version string is stored under __version__ attribute.
NumPy Array Creation
Creation of One-dimensional arrays
Creation of n-dimensional arrays
Example:
In this example, we are
creating a two-
dimensional array that
has the rank of 2 as it
has 2 axes. The first
axis(dimension) is of
length 2, i.e., the
number of rows, and
the second
axis(dimension) is of
length 3, i.e., the
number of columns.
The overall shape of
the array can be
represented as (2, 3)
Check Number of
Dimensions?
NumPy Arrays provides
the ndim attribute that returns an
integer that tells us how many
dimensions the array have.
NumPy Array Reshaping
Reshaping means changing the shape of an
array.
The shape of an array is the number of
elements in each dimension.
By reshaping we can add or remove
dimensions or change number of elements
in each dimension.
Reshape From 1-D to 2-D
Reshape From 1-D to 3-D
Can We Reshape Into any
Shape?
Yes, as long as the elements
required for reshaping are
equal in both shapes.
We can reshape an 8 elements
1D array into 4 elements in 2
rows 2D array but we cannot
reshape it into a 3 elements 3
rows 2D array as that would
require 3x3 = 9 elements.
Returns Copy or View?

More Related Content

PPTX
PPTX
1.NumPy is a Python library used for wor
PPTX
Introduction to numpy.pptx
PPTX
Numpy and Pandas Introduction for Beginners
PPTX
Introduction-to-NumPy-in-Python (1).pptx
PPTX
NumPy.pptx
PPTX
NumPy.pptx
PPTX
NUMPY [Autosaved] .pptx
1.NumPy is a Python library used for wor
Introduction to numpy.pptx
Numpy and Pandas Introduction for Beginners
Introduction-to-NumPy-in-Python (1).pptx
NumPy.pptx
NumPy.pptx
NUMPY [Autosaved] .pptx

Similar to NumPy.pptx Bachelor of Computer Application (20)

PPT
CAP776Numpy (2).ppt
PPT
CAP776Numpy.ppt
PPTX
Numpy in python, Array operations using numpy and so on
PPTX
NumPy.pptx
PPTX
Numpy.pptx
PPTX
numpydocococ34554367827839271966666.pptx
PPTX
THE NUMPY LIBRARY of python with slides.pptx
PDF
Numpy tutorial
PPTX
Numpy Library introducton in Python.pptx
PPTX
NUMPY-2.pptx
PDF
NumPy__data__anlysis___using__python.pdf
PDF
NumPy__data__anlysis___using__python.pdf
PPT
Introduction to Numpy Foundation Study GuideStudyGuide
PPTX
Introduction to numpy Session 1
DOCX
PDF
‏‏Lecture 2.pdf
PPTX
Data Analysis in Python-NumPy
PPTX
L-30-35huujjjhgjnnjhggbjkiuuhhjkiiijj.pptx
PPTX
Usage of Python NumPy, 1Dim, 2Dim Arrays
CAP776Numpy (2).ppt
CAP776Numpy.ppt
Numpy in python, Array operations using numpy and so on
NumPy.pptx
Numpy.pptx
numpydocococ34554367827839271966666.pptx
THE NUMPY LIBRARY of python with slides.pptx
Numpy tutorial
Numpy Library introducton in Python.pptx
NUMPY-2.pptx
NumPy__data__anlysis___using__python.pdf
NumPy__data__anlysis___using__python.pdf
Introduction to Numpy Foundation Study GuideStudyGuide
Introduction to numpy Session 1
‏‏Lecture 2.pdf
Data Analysis in Python-NumPy
L-30-35huujjjhgjnnjhggbjkiuuhhjkiiijj.pptx
Usage of Python NumPy, 1Dim, 2Dim Arrays
Ad

Recently uploaded (20)

PPTX
GDM (1) (1).pptx small presentation for students
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
Sports Quiz easy sports quiz sports quiz
PDF
01-Introduction-to-Information-Management.pdf
PPTX
master seminar digital applications in india
PPTX
Cell Structure & Organelles in detailed.
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PDF
RMMM.pdf make it easy to upload and study
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
Complications of Minimal Access Surgery at WLH
PPTX
Cell Types and Its function , kingdom of life
PPTX
Pharma ospi slides which help in ospi learning
PDF
Pre independence Education in Inndia.pdf
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
GDM (1) (1).pptx small presentation for students
Anesthesia in Laparoscopic Surgery in India
Supply Chain Operations Speaking Notes -ICLT Program
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
O7-L3 Supply Chain Operations - ICLT Program
Sports Quiz easy sports quiz sports quiz
01-Introduction-to-Information-Management.pdf
master seminar digital applications in india
Cell Structure & Organelles in detailed.
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
human mycosis Human fungal infections are called human mycosis..pptx
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
RMMM.pdf make it easy to upload and study
Microbial disease of the cardiovascular and lymphatic systems
STATICS OF THE RIGID BODIES Hibbelers.pdf
Complications of Minimal Access Surgery at WLH
Cell Types and Its function , kingdom of life
Pharma ospi slides which help in ospi learning
Pre independence Education in Inndia.pdf
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Ad

NumPy.pptx Bachelor of Computer Application

  • 1. What is NumPy? NumPy stands for Numerical Python. NumPy is a Python library used for working with arrays. It also has functions for working in domain of linear algebra, fourier transform, and matrices. NumPy was created in 2005 by Travis Oliphant. It is an open source project and you can use it freely. NumPy is a general-purpose array-processing package. It provides a high- performance multidimensional array object and tools for working with these arrays. It is the fundamental package for scientific computing with Python. Why Use NumPy? •In Python we have lists that serve the purpose of arrays, but they are slow to process. •NumPy aims to provide an array object that is up to 50x faster than traditional Python lists. •The array object in NumPy is called ndarray, it provides a lot of supporting functions that make working with ndarray very easy. •Arrays are very frequently used in data science, where speed and resources are very important.
  • 2. •It is capable of performing Fourier Transform and reshaping the data stored in multidimensional arrays. •NumPy provides the in-built functions for linear algebra and random number generation. Why is NumPy Faster Than Lists? NumPy arrays are stored at one continuous place in memory unlike lists, so processes can access and manipulate them very efficiently. This behavior is called locality of reference in computer science.This is the main reason why NumPy is faster than lists. Also it is optimized to work with latest CPU architectures. NumPy – Environment setup Standard Python distribution doesn't come bundled with NumPy module. A lightweight alternative is to install NumPy using popular Python package installer, pip. pip install numpy.
  • 3. NumPy as np NumPy is usually imported under the np alias. alias: In Python alias are an alternate name for referring to the same thing. Create an alias with the as keyword while importing: Checking NumPy Version The version string is stored under __version__ attribute.
  • 4. NumPy Array Creation Creation of One-dimensional arrays Creation of n-dimensional arrays
  • 5. Example: In this example, we are creating a two- dimensional array that has the rank of 2 as it has 2 axes. The first axis(dimension) is of length 2, i.e., the number of rows, and the second axis(dimension) is of length 3, i.e., the number of columns. The overall shape of the array can be represented as (2, 3)
  • 6. Check Number of Dimensions? NumPy Arrays provides the ndim attribute that returns an integer that tells us how many dimensions the array have. NumPy Array Reshaping Reshaping means changing the shape of an array. The shape of an array is the number of elements in each dimension. By reshaping we can add or remove dimensions or change number of elements in each dimension.
  • 7. Reshape From 1-D to 2-D Reshape From 1-D to 3-D Can We Reshape Into any Shape? Yes, as long as the elements required for reshaping are equal in both shapes. We can reshape an 8 elements 1D array into 4 elements in 2 rows 2D array but we cannot reshape it into a 3 elements 3 rows 2D array as that would require 3x3 = 9 elements.