SlideShare a Scribd company logo
1 of 18
Download to read offline
NumPy
What is NumPy?
❖Numerical python Package.
❖It is used for working with the scientific calculations ,Mathematical calculations
and general purpose of array processing.
❖ It provides a high performance multidimensional array object , and tools for
working with these arrays.
❖ Very fast than list.
❖ Elements in Numpy arrays are accessed by using square brackets and can be
initialized by using nested Python Lists.
Things to know in NumPy:-
❖ Difference between List and Numpy
❖Numpy alias name
❖nd array
❖Type of arrays
❖.ndim array
#Import numpy package
import numpy as np
a= np.array([12,78,456,90,10])
print(a)
arange()
import numpy as np
#print the values from 0 to 50 inside an array
a= np.arange(50)
print(a)
Updating array values
We can update the array values with the help of index.
a=[1,2,3,4,5]
a[1]=44
print(a)
reshape()
#To declare rows and columns of an array
import numpy as np
a=np.arange(15).reshape(5,3)
print(a)
#Accessing Array elements
a[1,1]
a[3,2]
Indexing
import numpy as np
# NumPy array with elements from 1 to 9
x = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9])
# Index values can be negative.
arr = x[ np. array([1, 3, -3])]
print(arr)
Boolean Indexing
This indexing has some boolean expression as the index. Those elements are
returned which satisfy that Boolean expression. It is used for filtering the desired
element values
import numpy as np
a = np.array([10, 40, 80, 50, 100])
print(a[a>50])
Slicing
import numpy as np
# Arrange elements from 0 to 19
a = np.arange(20)
print("n Array is:n ",a)
# a[ start:stop:step]
print("n a[-8:17:1] = ",a[-8:17:1])
# The : operator means all elements till the end.
print("n a[10:] = ",a[10:])
Basic operations on single array
import numpy as np
a = np.array([1, 2, 5, 3])
# add 1 to every element
print ("Adding 1 to every element:", a+1)
# subtract 3 from each element
print ("Subtracting 3 from each element:", a-3)
# multiply each element by 10
print ("Multiplying each element by 10:", a*10)
# square each element
print ("Squaring each element:", a**2)
Unary operators in numpy
import numpy as np
arr = np.array([[1, 5, 6], [4, 7, 2], [3, 1, 9]])
# maximum element of array
print ("Largest element is:", arr.max())
#print first columns in the array
print ("Row-wise maximum elements:", arr.max(axis = 1))
# minimum element of array
print ("Column-wise minimum elements:", arr.min(axis = 0))
# sum of array elements
print ("Sum of all array elements: “,arr.sum())
Binary operators in NumPy
import numpy as np
a = np.array([[1, 2], [3, 4]])
b = np.array([[4, 3],[2, 1]])
# add arrays
print ("Array sum:n", a + b)
# multiply arrays (element wise multiplication)
print ("Array multiplication:n", a*b)
# matrix multiplication
print ("Matrix multiplication:n", a.dot(b))
NumPy Functions:-
❖ To find the dimensional of the array - (arr_name.ndim)
❖To find the datatype of the array - (arr_name.dtype)
❖To copy the array elements - (arr_name.copy)
❖To viewing the array - (arr_name.view)
❖To change the data type of the array - (arr_name.astype(bool))

More Related Content

Similar to ACFrOgAabSLW3ZCRLJ0i-To_2fPk_pA9QThyDKNNlA3VK282MnXaLGJa7APKD15-TW9zT_QI98dAH5IOk2eYNgVYyu1dOTWKxFVJaorlNte-3MHkwdssPWXbcgzAPTlMuiQ4_Kkpyf9vaMj3LhdE.pdf

Similar to ACFrOgAabSLW3ZCRLJ0i-To_2fPk_pA9QThyDKNNlA3VK282MnXaLGJa7APKD15-TW9zT_QI98dAH5IOk2eYNgVYyu1dOTWKxFVJaorlNte-3MHkwdssPWXbcgzAPTlMuiQ4_Kkpyf9vaMj3LhdE.pdf (20)

NumPy.pptx
NumPy.pptxNumPy.pptx
NumPy.pptx
 
Numpy in Python.docx
Numpy in Python.docxNumpy in Python.docx
Numpy in Python.docx
 
Class 8b: Numpy & Matplotlib
Class 8b: Numpy & MatplotlibClass 8b: Numpy & Matplotlib
Class 8b: Numpy & Matplotlib
 
arraycreation.pptx
arraycreation.pptxarraycreation.pptx
arraycreation.pptx
 
Numpy
NumpyNumpy
Numpy
 
ARRAY OPERATIONS.pptx
ARRAY OPERATIONS.pptxARRAY OPERATIONS.pptx
ARRAY OPERATIONS.pptx
 
Python programming : Arrays
Python programming : ArraysPython programming : Arrays
Python programming : Arrays
 
Numpy_defintion_description_usage_examples.pptx
Numpy_defintion_description_usage_examples.pptxNumpy_defintion_description_usage_examples.pptx
Numpy_defintion_description_usage_examples.pptx
 
List,tuple,dictionary
List,tuple,dictionaryList,tuple,dictionary
List,tuple,dictionary
 
Numpy.pptx
Numpy.pptxNumpy.pptx
Numpy.pptx
 
ECE-PYTHON.docx
ECE-PYTHON.docxECE-PYTHON.docx
ECE-PYTHON.docx
 
NumPy.pptx
NumPy.pptxNumPy.pptx
NumPy.pptx
 
PPS-UNIT5.ppt
PPS-UNIT5.pptPPS-UNIT5.ppt
PPS-UNIT5.ppt
 
Arrays in python
Arrays in pythonArrays in python
Arrays in python
 
L 5 Numpy final ppt kirti.pptx
L 5 Numpy final ppt kirti.pptxL 5 Numpy final ppt kirti.pptx
L 5 Numpy final ppt kirti.pptx
 
SlideSet_4_Arraysnew.pdf
SlideSet_4_Arraysnew.pdfSlideSet_4_Arraysnew.pdf
SlideSet_4_Arraysnew.pdf
 
Arrays in python
Arrays in pythonArrays in python
Arrays in python
 
Arrays_in_c++.pptx
Arrays_in_c++.pptxArrays_in_c++.pptx
Arrays_in_c++.pptx
 
[ITP - Lecture 15] Arrays & its Types
[ITP - Lecture 15] Arrays & its Types[ITP - Lecture 15] Arrays & its Types
[ITP - Lecture 15] Arrays & its Types
 
CE344L-200365-Lab2.pdf
CE344L-200365-Lab2.pdfCE344L-200365-Lab2.pdf
CE344L-200365-Lab2.pdf
 

More from DineshThallapelly (6)

D.Sai Tharun 20848 BCA 2nd year-converted.pptx
D.Sai Tharun 20848 BCA 2nd year-converted.pptxD.Sai Tharun 20848 BCA 2nd year-converted.pptx
D.Sai Tharun 20848 BCA 2nd year-converted.pptx
 
IMG_20230326_134431 (15 files merged).ppt
IMG_20230326_134431 (15 files merged).pptIMG_20230326_134431 (15 files merged).ppt
IMG_20230326_134431 (15 files merged).ppt
 
IMG_20230325_121848 (13 files merged).ppt
IMG_20230325_121848 (13 files merged).pptIMG_20230325_121848 (13 files merged).ppt
IMG_20230325_121848 (13 files merged).ppt
 
ACFrOgDHQC5OjIl5Q9jxVubx7Sot2XrlBki_kWu7QeD_CcOBLjkoUqIWzF_pIdWB9F91KupVVJdfR...
ACFrOgDHQC5OjIl5Q9jxVubx7Sot2XrlBki_kWu7QeD_CcOBLjkoUqIWzF_pIdWB9F91KupVVJdfR...ACFrOgDHQC5OjIl5Q9jxVubx7Sot2XrlBki_kWu7QeD_CcOBLjkoUqIWzF_pIdWB9F91KupVVJdfR...
ACFrOgDHQC5OjIl5Q9jxVubx7Sot2XrlBki_kWu7QeD_CcOBLjkoUqIWzF_pIdWB9F91KupVVJdfR...
 
newmicrosoftofficepowerpointpresentation-160805121228 (1).pdf
newmicrosoftofficepowerpointpresentation-160805121228 (1).pdfnewmicrosoftofficepowerpointpresentation-160805121228 (1).pdf
newmicrosoftofficepowerpointpresentation-160805121228 (1).pdf
 
1601-308-Wright Brothers.pptx
1601-308-Wright Brothers.pptx1601-308-Wright Brothers.pptx
1601-308-Wright Brothers.pptx
 

Recently uploaded

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 

Recently uploaded (20)

Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 

ACFrOgAabSLW3ZCRLJ0i-To_2fPk_pA9QThyDKNNlA3VK282MnXaLGJa7APKD15-TW9zT_QI98dAH5IOk2eYNgVYyu1dOTWKxFVJaorlNte-3MHkwdssPWXbcgzAPTlMuiQ4_Kkpyf9vaMj3LhdE.pdf

  • 2. What is NumPy? ❖Numerical python Package. ❖It is used for working with the scientific calculations ,Mathematical calculations and general purpose of array processing. ❖ It provides a high performance multidimensional array object , and tools for working with these arrays. ❖ Very fast than list. ❖ Elements in Numpy arrays are accessed by using square brackets and can be initialized by using nested Python Lists.
  • 3. Things to know in NumPy:- ❖ Difference between List and Numpy ❖Numpy alias name ❖nd array ❖Type of arrays ❖.ndim array
  • 4. #Import numpy package import numpy as np a= np.array([12,78,456,90,10]) print(a)
  • 5.
  • 6.
  • 7.
  • 8.
  • 9. arange() import numpy as np #print the values from 0 to 50 inside an array a= np.arange(50) print(a)
  • 10. Updating array values We can update the array values with the help of index. a=[1,2,3,4,5] a[1]=44 print(a)
  • 11. reshape() #To declare rows and columns of an array import numpy as np a=np.arange(15).reshape(5,3) print(a) #Accessing Array elements a[1,1] a[3,2]
  • 12. Indexing import numpy as np # NumPy array with elements from 1 to 9 x = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9]) # Index values can be negative. arr = x[ np. array([1, 3, -3])] print(arr)
  • 13. Boolean Indexing This indexing has some boolean expression as the index. Those elements are returned which satisfy that Boolean expression. It is used for filtering the desired element values import numpy as np a = np.array([10, 40, 80, 50, 100]) print(a[a>50])
  • 14. Slicing import numpy as np # Arrange elements from 0 to 19 a = np.arange(20) print("n Array is:n ",a) # a[ start:stop:step] print("n a[-8:17:1] = ",a[-8:17:1]) # The : operator means all elements till the end. print("n a[10:] = ",a[10:])
  • 15. Basic operations on single array import numpy as np a = np.array([1, 2, 5, 3]) # add 1 to every element print ("Adding 1 to every element:", a+1) # subtract 3 from each element print ("Subtracting 3 from each element:", a-3) # multiply each element by 10 print ("Multiplying each element by 10:", a*10) # square each element print ("Squaring each element:", a**2)
  • 16. Unary operators in numpy import numpy as np arr = np.array([[1, 5, 6], [4, 7, 2], [3, 1, 9]]) # maximum element of array print ("Largest element is:", arr.max()) #print first columns in the array print ("Row-wise maximum elements:", arr.max(axis = 1)) # minimum element of array print ("Column-wise minimum elements:", arr.min(axis = 0)) # sum of array elements print ("Sum of all array elements: “,arr.sum())
  • 17. Binary operators in NumPy import numpy as np a = np.array([[1, 2], [3, 4]]) b = np.array([[4, 3],[2, 1]]) # add arrays print ("Array sum:n", a + b) # multiply arrays (element wise multiplication) print ("Array multiplication:n", a*b) # matrix multiplication print ("Matrix multiplication:n", a.dot(b))
  • 18. NumPy Functions:- ❖ To find the dimensional of the array - (arr_name.ndim) ❖To find the datatype of the array - (arr_name.dtype) ❖To copy the array elements - (arr_name.copy) ❖To viewing the array - (arr_name.view) ❖To change the data type of the array - (arr_name.astype(bool))