Numpy Training for Beginners
[Link]
Linear algebra library in Python
Used for performing mathematical and logical
operations on Arrays
What is Provides features for operations
dimensional arrays and matrices in Python
on multi-
Numpy?
[Link]
How to create Numpy Array?
[Link]
Creating Numpy Array
1D Array
Creating
Numpy Array 2D Array
[Link]
Ndarray Object
Most important object defined in NumPy is an N-
dimensional array type called ndarray
Describes the collection of items of the same type
What is
Items can be accessed using a zero-based index
Every item in an ndarray takes the same size of block
Numpy Array in the memory.
Each element in ndarray is an object of data-type
object (called dtype).
[Link]
How shall I
initialize the
numpy array?
Numpy Array Initialization
[Link]
Initializing Numpy Array
Initialize an array of ‘x’ X ‘y’ dimension with 0
Initializing
Numpy Array Arranging the numbers between x and y with an interval of z
[Link]
Initializing Numpy Array
Arranging ‘z’ numbers between x and y
Initializing
Numpy Array
[Link]
Initializing Numpy Array
Filling SAME number in a array of dimension x X y
Initializing
Numpy Array
Filling RANDOM numbers in a array of dimension x X y
[Link]
How to inspect
the created
array using
numpy?
Numpy Array Inspection
[Link]
[Link]
“Returns a tuple consisting of array dimensions. Can
also be used to resize the array.”
Numpy Array For Example,
Inspection
[Link]
[Link]
“Returns a tuple consisting of array dimensions. Can
also be used to resize the array.”
Numpy Array For Example,
Inspection
[Link]
[Link]
“Returns a tuple consisting of array dimensions. Can
also be used to resize the array.”
Numpy Array For Example,
Inspection
[Link]
[Link]
“Returns the count of number of elements in an array.”
Numpy Array For Example,
Inspection
[Link]
[Link]
“Returns the dimension of the array.”
For Example,
Numpy Array
Inspection
[Link]
[Link]
“Returns datatype of an array.”
For Example,
Numpy Array
Inspection
[Link]
Can we
perform some
mathematical
function using
numpy?
Numpy Array Mathematics
[Link]
Addition using Numpy
Numpy Array
Mathematics
[Link]
Other similar operations that you can perform:
[Link](a,b) #a-b
[Link](a,b) #a/b
Numpy Array [Link](a,b) #a*b
Mathematics [Link](a) #e^a
[Link](a)
[Link](a)
[Link](a)
[Link](a)
[Link]
Array Comparison
Element-wise Comparison
Numpy Array
Mathematics
Array-wise Comparison
[Link]
Aggregate Functions
Numpy Array
Mathematics
[Link]
Aggregate Functions
Numpy Array
Mathematics
[Link]
Concept of Broadcasting
Numpy
Broadcasting
[Link]
How to select
certain
elements from
the array?
Indexing and Slicing in Python
[Link]
Indexing in Python
“Index refers to a position .”
Numpy For Example,
Indexing and
Slicing
[Link]
Slicing
0 1 2
0
1 2 3
Numpy 1 4 5 6
Indexing and 2 7 8 9
Slicing Let’s learn to extract/slice the array
[Link]
Slicing
0 1 2
0
1 2 3
Numpy 1 4 5 6
Indexing and 2 7 8 9
Slicing How to extract the selected element?
My selection is in 1s t row = 0th index
A[0] ------#includes all the elements from the first row
A[:1] ------ #Extract first row from the array.
[Link]
Slicing
0 1 2
0
1 2 3
Numpy 1 4 5 6
Indexing and 2 7 8 9
Slicing How to extract the selected element?
My selection is in 1s t row = 0th index
A[:1] ------#Extracting till row = 0 (that is 0th row)
A[:1,1:]------#Extracting till row = 0 then
select the col index starting from 1 till last
[Link]
Slicing
0 1 2
0
1 2 3
Numpy 1 4 5 6
Indexing and 2 7 8 9
Slicing How to extract the selected element?
My selection is in 1s t two rows = 0,1 index
A[:2] ------#Extracting till row = 1 (that is 0,1)
A[:2,1:] ------ #Extracting till row = 1 (that is 0,1)
then select the col index starting from 1 till last
[Link]
Slicing
0 1 2
0
1 2 3
Numpy 1 4 5 6
Indexing and 2 7 8 9
Slicing How to extract the selected element?
My selection is in 1s t two rows = 0,1 index
A[1:,] ------#Extracting starts from row = 1 till end
A[1:,1:] ------ #Extracting starts from row = 1 till
end then select col index = 1 till end
[Link]
Slicing
Numpy
Indexing and
Slicing
[Link]
What are the
various
manipulations
done within the
array?
Array Manipulation in Python
[Link]
Concatenating two arrays together
Stack arrays row-wise(vertically)
Array
Manipulation Stack arrays column-wise(horizontally)
Combining column wise stacked array
[Link]
Splitting Arrays
Array
Manipulation
[Link]
Why should
I use Numpy
if I already
have a list?
Advantages of Numpy Array over List
[Link]
Why should I
use Numpy if
I already have
a list?
Why not List?
[Link]
What are the advantages of Numpy over List?
Advantages
of Numpy
over List
Consumes Faster More
Less Memory Convenient
[Link]
What are the advantages of Numpy over List?
Advantages
of Numpy
over List Pointers
1 element = 4 bytes
1 Object = 14bytes
[Link]
Numpy vs List: Memory Size
Advantages
of Numpy
over List
[Link]
Numpy vs List: Speed
Advantages
of Numpy
over List
[Link]
[Link]
India : +91-7847955955
US : 1-800-216-8930 (TOLL FREE)
sales@[Link]
[Link]