SlideShare a Scribd company logo
Outline
❑ Jupyter Notebook
❑ Numpy
❑ Importing Package
❑ Creating an Array
❑ Generating arrays using built-in functions
❑ Shape and Reshape an Array
❑ Numpy Operations
❑ Access Elements from an Array
❑ Advantages of Numpy
❑ Matrix operations
Jupyter Notebook
❑ Jupyter Notebook is a web-based interactive IDE for
Executing the Python.
❑ Install the Anaconda Navigator to your Machine and
open the Navigator.
Jupyter Notebook
❑ Launch the Jupyter Notebook; once Launch means (it
will take some time).
❑ Open the Jupyter Notebook (Type Jupyter Notebook in
Start Menu Search)
Importing Package
❑Numpy standards for Numerical Python
❑It is mainly used for handling the mathematical
operations.
❑Import the Numpy packages using import command
Package Name Alias Name of Numpy
Create an Array
❑Collection of ordered data elements of basic data types
❑Syntax: np.array(object)
Array List
Cont…
❑It handles different data types entries including integer,
float, string and so on.
int String
Run Time Inputs
number_list = [] n = int(input("Enter the list size "))
print("n")
for i in range(0, n):
print("Enter number at index", i, )
item = int(input())
number_list.append(item)
print("User list is ", number_list)
Generate arrays using linspace
❑np.linspace()-returns equally spaced numbers within the
given range based on the sample number
❑Syntax:
np.linspace(start,stop,num)
❑start -start of interval range
❑stop -end of interval range
❑num-number of samples to be generated
Generate arrays using arange()
❑np.arange()-returns equally spaced numbers with in the
given range based on step size
❑Syntax:
np.arange(start,stop,step)
❑start -start of interval range
❑stop -end of interval range
❑step -step size of interval
❑Generate an array with start=1and stop=100 by specifying
step=2
Generate arrays using zeros()
❑np.zeros()-returns an array of given shape and type
filled with zeros
❑Syntax:
np.zeros(shape,dtype)
❑shape -integer or sequence of integers
❑dtype-data type (default: float)
1-D
2-D
Generate arrays using ones()
❑np.ones()-returns an array of given shape and type
filled with ones
❑Syntax:
np.ones(shape,dtype)
❑shape -integer or sequence of integers
❑dtype-data type (default: float)
1-D 2-D
Generate arrays using eye()
❑np.eye()-returns an array of given shape and diagonals
are filled with ones and rest of the diagonals are filled with
zeros.
❑Syntax:
np.eye(shape)
Generate arrays using random.rand()
❑np.random.rand()-returns an array of given shape filled
with random values
❑Syntax: numpy.random.rand(shape)
❑shape -integer or sequence of integers
❑The range of random number should be between 0-1
1-D
2-D
Shape an array
❑np.shape()-returns dimension of an array
❑Syntax: np.shape(var)
1-D 2-D
❑In 1-D, return shape as 5
❑In 2-D, will return 2rows and 3 columns.
Reshape an array
❑reshape()-returns an array to new shape without
changing its data
❑Syntax: reshape(dimension)
Numpy addition
❑np.sum()-returns sum of all array elements
❑Syntax: np.sum(array,axis)
❑array() –input array
❑axis() –axis along which sum should be calculated
❑If axis= None ; calculate overall sum
Numpy addition
❑if axis=0; calculate sum along with column wise
❑If axis=1; calculate sum along with row wise
Column wise sum Row wise sum
Numpy addition
❑np.add()-performs element wise addition between two
arrays
❑Syntax: np.add(array_1,array_2)
❑Create two arrays a and b
Output
Numpy subtraction
❑np.subtract()-performs element wise subtraction between
two arrays
❑Syntax: np.subtract(array_1,array_2)
❑Create two arrays a and b
Output
Numpy multiply
❑np.multiply()-performs element wise multiplication
between two arrays
❑Syntax: np.multiply(array_1,array_2)
❑Create two arrays a and b
Output
Numpy divide
❑np.divide()-performs element wise divide operation
between two arrays
❑Syntax: np.divide(array_1,array_2)
❑Create two arrays a and b
Output
Numpy remainder
❑np.remainder()-performs element wise remainder
between two arrays
❑Syntax: np.remainder(array_1,array_2)
❑Create two arrays a and b
Output
Accessing components of an array
❑Components of an array can be accessed using index
number
Subset of arrays
❖Subset a 2x2 array from the original
array m
❖Consider the first two rows and
columns from m
❖Print subset array sub
Subset of arrays
❖Here the value 1should be updated to 12
❖Print the updated array
❖Modifying the subset will automatically update the
original array also
Transpose of an array
np.transpose()- permute the dimensions of array
❑Syntax: np.transpose(array)
Output
Advantages of Numpy
❑timeit module can be used to measure the execution time
for snippets of code
❑Comparing the processing speed of a list and an array
using an addition operation
List Array
❑Creating a list ❑Creating a array
Create a Matrix
❑matrix()- returns a matrix from an array type object or
string of data
❑Syntax: np.matrix(data)
❑shape- returns number of rows and columns from a
matrix
❑shape[0]- returns the no. of row
❑shape[1]-returns the no. of columns.
❑size()- returns total no of elements.
Modifying matrix using insert()
❑insert()- adds values at a given position and axis in a
matrix
❑Syntax: np.insert(matrix, obj, values, axis)
❑marix- input matrix
❑obj- index position
❑values-matrix of values to be inserted
❑axis- axis=0- row insert otherwise- column wise insertion
Matrix Operations
Row Insertion Column Insertion
S.
No.
Function Description
1. np.add(M1,M2) Performs element wise addition between
two matrix
2. np.subtract(M1,M
2)
Performs element wise subtraction between
two matrix
3. np.dot(M1,M2) Performs element wise multiplication
between two matrix
4. np.divide(M1,M2) Performs element wise division between
two matrix
Any Queries ?

More Related Content

PPTX
NUMPY LIBRARY study materials PPT 2.pptx
PPTX
NumPy-python-27-9-24-we.pptxNumPy-python-27-9-24-we.pptx
PDF
Numpy python cheat_sheet
PDF
Numpy python cheat_sheet
PDF
CE344L-200365-Lab2.pdf
PDF
Python_cheatsheet_numpy.pdf
PPTX
PPTX
Introduction to numpy Session 1
NUMPY LIBRARY study materials PPT 2.pptx
NumPy-python-27-9-24-we.pptxNumPy-python-27-9-24-we.pptx
Numpy python cheat_sheet
Numpy python cheat_sheet
CE344L-200365-Lab2.pdf
Python_cheatsheet_numpy.pdf
Introduction to numpy Session 1

Similar to Numpy_defintion_description_usage_examples.pptx (20)

PPTX
NUMPY [Autosaved] .pptx
PDF
ACFrOgAabSLW3ZCRLJ0i-To_2fPk_pA9QThyDKNNlA3VK282MnXaLGJa7APKD15-TW9zT_QI98dAH...
PPTX
THE NUMPY LIBRARY of python with slides.pptx
PDF
Essential numpy before you start your Machine Learning journey in python.pdf
PPT
Python crash course libraries numpy-1, panda.ppt
PPTX
Arrays with Numpy, Computer Graphics
PPT
Introduction to Numpy Foundation Study GuideStudyGuide
PPTX
Introduction-to-NumPy-in-Python (1).pptx
PPT
CAP776Numpy (2).ppt
PPT
CAP776Numpy.ppt
PDF
‏‏Lecture 2.pdf
PPTX
Data Preprocessing Introduction for Machine Learning
PDF
Numpy cheat-sheet
PPTX
Numpy in python, Array operations using numpy and so on
PPTX
numpydocococ34554367827839271966666.pptx
PDF
Numpy - Array.pdf
PDF
Concept of Data science and Numpy concept
PPTX
Usage of Python NumPy, 1Dim, 2Dim Arrays
PDF
Numpy_Cheat_Sheet.pdf
PPTX
L 5 Numpy final learning and Coding
NUMPY [Autosaved] .pptx
ACFrOgAabSLW3ZCRLJ0i-To_2fPk_pA9QThyDKNNlA3VK282MnXaLGJa7APKD15-TW9zT_QI98dAH...
THE NUMPY LIBRARY of python with slides.pptx
Essential numpy before you start your Machine Learning journey in python.pdf
Python crash course libraries numpy-1, panda.ppt
Arrays with Numpy, Computer Graphics
Introduction to Numpy Foundation Study GuideStudyGuide
Introduction-to-NumPy-in-Python (1).pptx
CAP776Numpy (2).ppt
CAP776Numpy.ppt
‏‏Lecture 2.pdf
Data Preprocessing Introduction for Machine Learning
Numpy cheat-sheet
Numpy in python, Array operations using numpy and so on
numpydocococ34554367827839271966666.pptx
Numpy - Array.pdf
Concept of Data science and Numpy concept
Usage of Python NumPy, 1Dim, 2Dim Arrays
Numpy_Cheat_Sheet.pdf
L 5 Numpy final learning and Coding
Ad

More from VGaneshKarthikeyan (20)

PPT
1.3 Basic coding skills_fundamentals .ppt
PPT
5_Model for Predictions_Machine_Learning.ppt
PPT
2_Errors in Experimental Observations_ML.ppt
PDF
FINAL_DAY11_INTERFACES_Roles_and_Responsibility.pdf
PPTX
FINAL_DAY10_INTERFACES_roles and benefits.pptx
PPTX
FINAL_DAY8_VISIBILITY_LABELS_Roles and.pptx
PPTX
FINAL_DAY9_METHOD_OVERRIDING_Role and benefits .pptx
PPT
JAVA_BASICS_Data_abstraction_encapsulation.ppt
PPT
Java ppt-class_Introduction_class_Objects.ppt
PPT
INT104 DBMS - Introduction_Atomicity.ppt
PDF
6. Implementation of classes_and_its_advantages.pdf
PPT
Operators_in_C++_advantages_applications.ppt
PPT
1_Standard error Experimental Data_ML.ppt
PPTX
Unit III Part I_Opertaor_Overloading.pptx
PPTX
Linear_discriminat_analysis_in_Machine_Learning.pptx
PPTX
K-Mean clustering_Introduction_Applications.pptx
PPT
Refined_Lecture-14-Linear Algebra-Review.ppt
PPT
randomwalks_states_figures_events_happenings.ppt
PPT
stochasticmodellinganditsapplications.ppt
PPTX
1.10 Tuples_sets_usage_applications_advantages.pptx
1.3 Basic coding skills_fundamentals .ppt
5_Model for Predictions_Machine_Learning.ppt
2_Errors in Experimental Observations_ML.ppt
FINAL_DAY11_INTERFACES_Roles_and_Responsibility.pdf
FINAL_DAY10_INTERFACES_roles and benefits.pptx
FINAL_DAY8_VISIBILITY_LABELS_Roles and.pptx
FINAL_DAY9_METHOD_OVERRIDING_Role and benefits .pptx
JAVA_BASICS_Data_abstraction_encapsulation.ppt
Java ppt-class_Introduction_class_Objects.ppt
INT104 DBMS - Introduction_Atomicity.ppt
6. Implementation of classes_and_its_advantages.pdf
Operators_in_C++_advantages_applications.ppt
1_Standard error Experimental Data_ML.ppt
Unit III Part I_Opertaor_Overloading.pptx
Linear_discriminat_analysis_in_Machine_Learning.pptx
K-Mean clustering_Introduction_Applications.pptx
Refined_Lecture-14-Linear Algebra-Review.ppt
randomwalks_states_figures_events_happenings.ppt
stochasticmodellinganditsapplications.ppt
1.10 Tuples_sets_usage_applications_advantages.pptx
Ad

Recently uploaded (20)

PDF
Human-AI Collaboration: Balancing Agentic AI and Autonomy in Hybrid Systems
PPTX
6ME3A-Unit-II-Sensors and Actuators_Handouts.pptx
PDF
Integrating Fractal Dimension and Time Series Analysis for Optimized Hyperspe...
PPTX
introduction to high performance computing
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
PDF
Visual Aids for Exploratory Data Analysis.pdf
PPT
introduction to datamining and warehousing
PDF
86236642-Electric-Loco-Shed.pdf jfkduklg
PDF
737-MAX_SRG.pdf student reference guides
PDF
Exploratory_Data_Analysis_Fundamentals.pdf
PPTX
UNIT 4 Total Quality Management .pptx
PDF
BIO-INSPIRED HORMONAL MODULATION AND ADAPTIVE ORCHESTRATION IN S-AI-GPT
PDF
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PPTX
Nature of X-rays, X- Ray Equipment, Fluoroscopy
PPTX
Safety Seminar civil to be ensured for safe working.
PPT
Occupational Health and Safety Management System
PDF
PREDICTION OF DIABETES FROM ELECTRONIC HEALTH RECORDS
PDF
Soil Improvement Techniques Note - Rabbi
PDF
BIO-INSPIRED ARCHITECTURE FOR PARSIMONIOUS CONVERSATIONAL INTELLIGENCE : THE ...
Human-AI Collaboration: Balancing Agentic AI and Autonomy in Hybrid Systems
6ME3A-Unit-II-Sensors and Actuators_Handouts.pptx
Integrating Fractal Dimension and Time Series Analysis for Optimized Hyperspe...
introduction to high performance computing
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
Visual Aids for Exploratory Data Analysis.pdf
introduction to datamining and warehousing
86236642-Electric-Loco-Shed.pdf jfkduklg
737-MAX_SRG.pdf student reference guides
Exploratory_Data_Analysis_Fundamentals.pdf
UNIT 4 Total Quality Management .pptx
BIO-INSPIRED HORMONAL MODULATION AND ADAPTIVE ORCHESTRATION IN S-AI-GPT
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
Nature of X-rays, X- Ray Equipment, Fluoroscopy
Safety Seminar civil to be ensured for safe working.
Occupational Health and Safety Management System
PREDICTION OF DIABETES FROM ELECTRONIC HEALTH RECORDS
Soil Improvement Techniques Note - Rabbi
BIO-INSPIRED ARCHITECTURE FOR PARSIMONIOUS CONVERSATIONAL INTELLIGENCE : THE ...

Numpy_defintion_description_usage_examples.pptx

  • 1. Outline ❑ Jupyter Notebook ❑ Numpy ❑ Importing Package ❑ Creating an Array ❑ Generating arrays using built-in functions ❑ Shape and Reshape an Array ❑ Numpy Operations ❑ Access Elements from an Array ❑ Advantages of Numpy ❑ Matrix operations
  • 2. Jupyter Notebook ❑ Jupyter Notebook is a web-based interactive IDE for Executing the Python. ❑ Install the Anaconda Navigator to your Machine and open the Navigator.
  • 3. Jupyter Notebook ❑ Launch the Jupyter Notebook; once Launch means (it will take some time). ❑ Open the Jupyter Notebook (Type Jupyter Notebook in Start Menu Search)
  • 4. Importing Package ❑Numpy standards for Numerical Python ❑It is mainly used for handling the mathematical operations. ❑Import the Numpy packages using import command Package Name Alias Name of Numpy
  • 5. Create an Array ❑Collection of ordered data elements of basic data types ❑Syntax: np.array(object) Array List
  • 6. Cont… ❑It handles different data types entries including integer, float, string and so on. int String
  • 7. Run Time Inputs number_list = [] n = int(input("Enter the list size ")) print("n") for i in range(0, n): print("Enter number at index", i, ) item = int(input()) number_list.append(item) print("User list is ", number_list)
  • 8. Generate arrays using linspace ❑np.linspace()-returns equally spaced numbers within the given range based on the sample number ❑Syntax: np.linspace(start,stop,num) ❑start -start of interval range ❑stop -end of interval range ❑num-number of samples to be generated
  • 9. Generate arrays using arange() ❑np.arange()-returns equally spaced numbers with in the given range based on step size ❑Syntax: np.arange(start,stop,step) ❑start -start of interval range ❑stop -end of interval range ❑step -step size of interval ❑Generate an array with start=1and stop=100 by specifying step=2
  • 10. Generate arrays using zeros() ❑np.zeros()-returns an array of given shape and type filled with zeros ❑Syntax: np.zeros(shape,dtype) ❑shape -integer or sequence of integers ❑dtype-data type (default: float) 1-D 2-D
  • 11. Generate arrays using ones() ❑np.ones()-returns an array of given shape and type filled with ones ❑Syntax: np.ones(shape,dtype) ❑shape -integer or sequence of integers ❑dtype-data type (default: float) 1-D 2-D
  • 12. Generate arrays using eye() ❑np.eye()-returns an array of given shape and diagonals are filled with ones and rest of the diagonals are filled with zeros. ❑Syntax: np.eye(shape)
  • 13. Generate arrays using random.rand() ❑np.random.rand()-returns an array of given shape filled with random values ❑Syntax: numpy.random.rand(shape) ❑shape -integer or sequence of integers ❑The range of random number should be between 0-1 1-D 2-D
  • 14. Shape an array ❑np.shape()-returns dimension of an array ❑Syntax: np.shape(var) 1-D 2-D ❑In 1-D, return shape as 5 ❑In 2-D, will return 2rows and 3 columns.
  • 15. Reshape an array ❑reshape()-returns an array to new shape without changing its data ❑Syntax: reshape(dimension)
  • 16. Numpy addition ❑np.sum()-returns sum of all array elements ❑Syntax: np.sum(array,axis) ❑array() –input array ❑axis() –axis along which sum should be calculated ❑If axis= None ; calculate overall sum
  • 17. Numpy addition ❑if axis=0; calculate sum along with column wise ❑If axis=1; calculate sum along with row wise Column wise sum Row wise sum
  • 18. Numpy addition ❑np.add()-performs element wise addition between two arrays ❑Syntax: np.add(array_1,array_2) ❑Create two arrays a and b Output
  • 19. Numpy subtraction ❑np.subtract()-performs element wise subtraction between two arrays ❑Syntax: np.subtract(array_1,array_2) ❑Create two arrays a and b Output
  • 20. Numpy multiply ❑np.multiply()-performs element wise multiplication between two arrays ❑Syntax: np.multiply(array_1,array_2) ❑Create two arrays a and b Output
  • 21. Numpy divide ❑np.divide()-performs element wise divide operation between two arrays ❑Syntax: np.divide(array_1,array_2) ❑Create two arrays a and b Output
  • 22. Numpy remainder ❑np.remainder()-performs element wise remainder between two arrays ❑Syntax: np.remainder(array_1,array_2) ❑Create two arrays a and b Output
  • 23. Accessing components of an array ❑Components of an array can be accessed using index number
  • 24. Subset of arrays ❖Subset a 2x2 array from the original array m ❖Consider the first two rows and columns from m ❖Print subset array sub
  • 25. Subset of arrays ❖Here the value 1should be updated to 12 ❖Print the updated array ❖Modifying the subset will automatically update the original array also
  • 26. Transpose of an array np.transpose()- permute the dimensions of array ❑Syntax: np.transpose(array) Output
  • 27. Advantages of Numpy ❑timeit module can be used to measure the execution time for snippets of code ❑Comparing the processing speed of a list and an array using an addition operation List Array ❑Creating a list ❑Creating a array
  • 28. Create a Matrix ❑matrix()- returns a matrix from an array type object or string of data ❑Syntax: np.matrix(data) ❑shape- returns number of rows and columns from a matrix ❑shape[0]- returns the no. of row ❑shape[1]-returns the no. of columns. ❑size()- returns total no of elements.
  • 29. Modifying matrix using insert() ❑insert()- adds values at a given position and axis in a matrix ❑Syntax: np.insert(matrix, obj, values, axis) ❑marix- input matrix ❑obj- index position ❑values-matrix of values to be inserted ❑axis- axis=0- row insert otherwise- column wise insertion
  • 30. Matrix Operations Row Insertion Column Insertion S. No. Function Description 1. np.add(M1,M2) Performs element wise addition between two matrix 2. np.subtract(M1,M 2) Performs element wise subtraction between two matrix 3. np.dot(M1,M2) Performs element wise multiplication between two matrix 4. np.divide(M1,M2) Performs element wise division between two matrix