SlideShare a Scribd company logo
5
Most read
11
Most read
14
Most read
-Jyoti Shukla(SME)
Topics
 Introduction of Numpy
 Indexing & slicing
 Mathematical computation
 Array comparison
 array Manipulation
 transpose & swapcase
 insert and remove
Topics
 What is Numpy?
 Why Numpy?
 What is Array?
 Dimensions in Arrays
 Initialization of an Array.
What is Numerical Python?
 NumPy is the fundamental package for scientific
computing with Python.
 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
Why NumPy?
 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.
Arrays
 NumPy’s main object is the homogeneous
multidimensional array.
 It is a table of elements (usually numbers), all of the
same type, indexed by a tuple of positive integers.
 In NumPy dimensions are called axes. The number of
axes is rank.
 NumPy’s array class is called ndarray. It is also known
by the alias array.
Dimensions in Arrays
 A dimension in arrays is one level of array depth
1-D Arrays
 An array that has 0-D arrays as its elements is called
uni-dimensional or 1-D array.These are the most
common and basic arrays.
 import numpy as np
arr = np.array([1, 2, 3, 4, 5])
print(arr)
Numpy
2-D Arrays
 An array that has 1-D arrays as its elements is called a
2-D array.These are often used to represent matrix or
2nd order tensors.
 import numpy as np
arr = np.array([[1, 2, 3], [4, 5, 6]])
print(arr)
3-D arrays
 An array that has 2-D arrays (matrices) as its elements
is called 3-D array.These are often used to represent a
3rd order tensor.
 import numpy as np
arr = np.array([[[1, 2, 3], [4, 5, 6]], [[1, 2, 3], [4, 5, 6]]])
print(arr)
INITIALIZTION
np.array([1,2,3]) 1d array
np.array([(1,2,3),(4,5,6)]) 2d array
np.arange(start,stop,step) range array
np.linspace(0,2,9)
Add evenly spaced values btw interval to array of
length
np.zeros((1,2)) Create and array filled with zeros
np.ones((1,2)) Creates an array filled with ones
np.random.random((5,5)) Creates random array
np.empty((2,2)) Creates an empty array
ARRAY PROPERTIES
Syntax Description
array.shape Dimensions (Rows,Columns)
len(array) Length of Array
array.ndim Number of Array Dimensions
array.size Number of Array Elements
array.dtype Data Type
type(array) Type of Array
COPYING/SORTING
np.copy(array) Creates copy of array
array.sort() Sorts an array
array.sort(axis=0) Sorts axis of array
Operations
Operator Description
np.add(x,y)
x + y
Addition
np.substract(x,y)
x – y
Subtraction
np.divide(x,y)
x / y
Division
np.multiply(x,y)
x @ y
Multiplication
np.sqrt(x) Square Root
np.sin(x) Element-wise sine
np.cos(x) Element-wise cosine
np.log(x) Element-wise natural log
np.dot(x,y) Dot product
np.roots([1,0,-4]) Roots of a given polynomial coefficients

More Related Content

PPTX
PDF
Python NumPy Tutorial | NumPy Array | Edureka
PPTX
MatplotLib.pptx
PPTX
Pandas
PPTX
Introduction to pandas
PDF
Introduction to NumPy (PyData SV 2013)
Python NumPy Tutorial | NumPy Array | Edureka
MatplotLib.pptx
Pandas
Introduction to pandas
Introduction to NumPy (PyData SV 2013)

What's hot (20)

PPTX
Introduction to numpy Session 1
PPTX
NumPy.pptx
PPT
PDF
Python programming : Files
PPT
Lecture 1 data structures and algorithms
PDF
Introduction to NumPy
PDF
Python libraries
PPT
Python Pandas
PPTX
Introduction to numpy
PDF
Python list
PDF
List,tuple,dictionary
PPTX
Divide and conquer 1
PDF
Python Matplotlib Tutorial | Matplotlib Tutorial | Python Tutorial | Python T...
ODP
Python Modules
PDF
Arrays In Python | Python Array Operations | Edureka
PPTX
Introduction to matplotlib
PDF
PPTX
Machine learning with scikitlearn
PPTX
Data Analysis in Python-NumPy
Introduction to numpy Session 1
NumPy.pptx
Python programming : Files
Lecture 1 data structures and algorithms
Introduction to NumPy
Python libraries
Python Pandas
Introduction to numpy
Python list
List,tuple,dictionary
Divide and conquer 1
Python Matplotlib Tutorial | Matplotlib Tutorial | Python Tutorial | Python T...
Python Modules
Arrays In Python | Python Array Operations | Edureka
Introduction to matplotlib
Machine learning with scikitlearn
Data Analysis in Python-NumPy
Ad

Similar to Numpy (20)

PPTX
NumPy.pptx
PPTX
1.NumPy is a Python library used for wor
PPTX
NumPy-python-27-9-24-we.pptxNumPy-python-27-9-24-we.pptx
PPTX
NUMPY-2.pptx
PPTX
Lecture 2 _Foundions foundions NumPyI.pptx
PPTX
Numpy in python, Array operations using numpy and so on
PPTX
numpy code and examples with attributes.pptx
PPTX
NUMPY [Autosaved] .pptx
PPTX
Data Preprocessing Introduction for Machine Learning
PPTX
numpydocococ34554367827839271966666.pptx
PPT
PPTX
Presentation1.pptxvghvfhgvbn nbnmbnbjkbjkbjib
PDF
ACFrOgAabSLW3ZCRLJ0i-To_2fPk_pA9QThyDKNNlA3VK282MnXaLGJa7APKD15-TW9zT_QI98dAH...
PDF
PPTX
L 5 Numpy final learning and Coding
PPTX
Introduction-to-NumPy-in-Python (1).pptx
PPT
CAP776Numpy.ppt
PPT
CAP776Numpy (2).ppt
PDF
Numpy - Array.pdf
PPTX
object oriented programing in python and pip
NumPy.pptx
1.NumPy is a Python library used for wor
NumPy-python-27-9-24-we.pptxNumPy-python-27-9-24-we.pptx
NUMPY-2.pptx
Lecture 2 _Foundions foundions NumPyI.pptx
Numpy in python, Array operations using numpy and so on
numpy code and examples with attributes.pptx
NUMPY [Autosaved] .pptx
Data Preprocessing Introduction for Machine Learning
numpydocococ34554367827839271966666.pptx
Presentation1.pptxvghvfhgvbn nbnmbnbjkbjkbjib
ACFrOgAabSLW3ZCRLJ0i-To_2fPk_pA9QThyDKNNlA3VK282MnXaLGJa7APKD15-TW9zT_QI98dAH...
L 5 Numpy final learning and Coding
Introduction-to-NumPy-in-Python (1).pptx
CAP776Numpy.ppt
CAP776Numpy (2).ppt
Numpy - Array.pdf
object oriented programing in python and pip
Ad

Recently uploaded (20)

PDF
.pdf is not working space design for the following data for the following dat...
PPTX
CEE 2 REPORT G7.pptxbdbshjdgsgjgsjfiuhsd
PPTX
Computer network topology notes for revision
PDF
Mega Projects Data Mega Projects Data
PPTX
Business Ppt On Nestle.pptx huunnnhhgfvu
PPTX
mbdjdhjjodule 5-1 rhfhhfjtjjhafbrhfnfbbfnb
PPTX
Major-Components-ofNKJNNKNKNKNKronment.pptx
PPTX
05. PRACTICAL GUIDE TO MICROSOFT EXCEL.pptx
PPT
Reliability_Chapter_ presentation 1221.5784
PPT
Chapter 2 METAL FORMINGhhhhhhhjjjjmmmmmmmmm
PPTX
IB Computer Science - Internal Assessment.pptx
PPTX
iec ppt-1 pptx icmr ppt on rehabilitation.pptx
PPTX
Database Infoormation System (DBIS).pptx
PPTX
Business Acumen Training GuidePresentation.pptx
PPTX
MODULE 8 - DISASTER risk PREPAREDNESS.pptx
PDF
Foundation of Data Science unit number two notes
PDF
Lecture1 pattern recognition............
PDF
BF and FI - Blockchain, fintech and Financial Innovation Lesson 2.pdf
PPTX
1_Introduction to advance data techniques.pptx
PPTX
Moving the Public Sector (Government) to a Digital Adoption
.pdf is not working space design for the following data for the following dat...
CEE 2 REPORT G7.pptxbdbshjdgsgjgsjfiuhsd
Computer network topology notes for revision
Mega Projects Data Mega Projects Data
Business Ppt On Nestle.pptx huunnnhhgfvu
mbdjdhjjodule 5-1 rhfhhfjtjjhafbrhfnfbbfnb
Major-Components-ofNKJNNKNKNKNKronment.pptx
05. PRACTICAL GUIDE TO MICROSOFT EXCEL.pptx
Reliability_Chapter_ presentation 1221.5784
Chapter 2 METAL FORMINGhhhhhhhjjjjmmmmmmmmm
IB Computer Science - Internal Assessment.pptx
iec ppt-1 pptx icmr ppt on rehabilitation.pptx
Database Infoormation System (DBIS).pptx
Business Acumen Training GuidePresentation.pptx
MODULE 8 - DISASTER risk PREPAREDNESS.pptx
Foundation of Data Science unit number two notes
Lecture1 pattern recognition............
BF and FI - Blockchain, fintech and Financial Innovation Lesson 2.pdf
1_Introduction to advance data techniques.pptx
Moving the Public Sector (Government) to a Digital Adoption

Numpy

  • 2. Topics  Introduction of Numpy  Indexing & slicing  Mathematical computation  Array comparison  array Manipulation  transpose & swapcase  insert and remove
  • 3. Topics  What is Numpy?  Why Numpy?  What is Array?  Dimensions in Arrays  Initialization of an Array.
  • 4. What is Numerical Python?  NumPy is the fundamental package for scientific computing with Python.  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
  • 5. Why NumPy?  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.
  • 6. Arrays  NumPy’s main object is the homogeneous multidimensional array.  It is a table of elements (usually numbers), all of the same type, indexed by a tuple of positive integers.  In NumPy dimensions are called axes. The number of axes is rank.  NumPy’s array class is called ndarray. It is also known by the alias array.
  • 7. Dimensions in Arrays  A dimension in arrays is one level of array depth 1-D Arrays  An array that has 0-D arrays as its elements is called uni-dimensional or 1-D array.These are the most common and basic arrays.  import numpy as np arr = np.array([1, 2, 3, 4, 5]) print(arr)
  • 9. 2-D Arrays  An array that has 1-D arrays as its elements is called a 2-D array.These are often used to represent matrix or 2nd order tensors.  import numpy as np arr = np.array([[1, 2, 3], [4, 5, 6]]) print(arr)
  • 10. 3-D arrays  An array that has 2-D arrays (matrices) as its elements is called 3-D array.These are often used to represent a 3rd order tensor.  import numpy as np arr = np.array([[[1, 2, 3], [4, 5, 6]], [[1, 2, 3], [4, 5, 6]]]) print(arr)
  • 11. INITIALIZTION np.array([1,2,3]) 1d array np.array([(1,2,3),(4,5,6)]) 2d array np.arange(start,stop,step) range array np.linspace(0,2,9) Add evenly spaced values btw interval to array of length np.zeros((1,2)) Create and array filled with zeros np.ones((1,2)) Creates an array filled with ones np.random.random((5,5)) Creates random array np.empty((2,2)) Creates an empty array
  • 12. ARRAY PROPERTIES Syntax Description array.shape Dimensions (Rows,Columns) len(array) Length of Array array.ndim Number of Array Dimensions array.size Number of Array Elements array.dtype Data Type type(array) Type of Array
  • 13. COPYING/SORTING np.copy(array) Creates copy of array array.sort() Sorts an array array.sort(axis=0) Sorts axis of array
  • 14. Operations Operator Description np.add(x,y) x + y Addition np.substract(x,y) x – y Subtraction np.divide(x,y) x / y Division np.multiply(x,y) x @ y Multiplication np.sqrt(x) Square Root np.sin(x) Element-wise sine np.cos(x) Element-wise cosine np.log(x) Element-wise natural log np.dot(x,y) Dot product np.roots([1,0,-4]) Roots of a given polynomial coefficients