0% found this document useful (0 votes)
5 views44 pages

Python Session 5

The document provides an overview of NumPy, a powerful Python library for numerical computing, emphasizing its efficiency in handling arrays compared to traditional Python lists. It explains the concept of n-dimensional arrays, their structure, and how to create and manipulate them using NumPy. Additionally, the document outlines the session's agenda, activities, and applications of NumPy.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views44 pages

Python Session 5

The document provides an overview of NumPy, a powerful Python library for numerical computing, emphasizing its efficiency in handling arrays compared to traditional Python lists. It explains the concept of n-dimensional arrays, their structure, and how to create and manipulate them using NumPy. Additionally, the document outlines the session's agenda, activities, and applications of NumPy.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 44

Python

NumPy
Session V
Norms

Take Notes! Do It With Me! Participate!


Agenda
1. What is NumPy?
2. Applications of NumPy!
What is NumPy?
NumPy!
● NumPy stands for Numerical Python.
● It’s a Python library used for working with
an array.
● In Python, we use the list for purpose of the
array but it’s slow to process.
NumPy!
● It is a powerful N-dimensional array
object and its use in Linear algebra,
Fourier transform, Matrices and
random number capabilities.
● Provides an array object much faster
than traditional Python lists.
NumPy!
● The array object in NumPy is called
ndarray(n dimensional array).
● It provides a lot of supporting functions
that make working with ndarray very
easy.
Why NumPy is faster than Lists?
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.
What is an Array?
Array!
● Array is a container which can hold a fix
number of items and these items should be
of the same type.
● Most of the data structures make use of
arrays to implement their algorithms.
Array!
● Following are the important terms to
understand the concept of Array.
○ Element− Each item stored in an array
is called an element.
○ Index − Each location of an element in
an array has a numerical index, which
is used to identify the element.
Array!
What is an N-dimensional array?
N-dimensional array!
● An ndarray is a (usually fixed-size)
multidimensional container of items of
the same type and size.
● The number of dimensions and items in
an array is defined by its shape, which
is a tuple of non-negative integers that
specify the sizes of each dimension.
N-dimensional array!
● The type of items in the array is
specified by a separate data-type
object (dtype), one of which is
associated with each ndarray.
Have you understood the difference
between arrays and ndarrays?
How to work with NumPy arrays?
Numpy arrays!
● Install it using this command:

C:\Users\Your Name>pip install numpy


Numpy arrays!
Numpy arrays!
NumPy as np
How to create NumPy arrays?
Numpy arrays!
Creating a NumPy array.
What are the different dimensions of
NumPy arrays?
Numpy arrays!
0-D arrays, or Scalars, are the elements in an array. Each value in an
array is a 0-D array
Numpy arrays!
1D-Array: 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.
Numpy arrays!
2D-Array: 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.
Numpy arrays!
3D-Array: 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.
Activity!
● Create an 2-dimensional array, where a list is
passed through a tuple.
Numpy arrays!
Checking number of dimensions:
Numpy arrays!
NumPy Array Indexing:
Numpy arrays!
NumPy Array Indexing:
Activity!

● Access 3rd element of 2nd row from given


n-d array.

([[[ 0, 1, 2, 3], [ 4, 5, 6, 7], [ 8, 9, 10, 11]], [[12, 13, 14, 15], [16, 17,
18, 19]]])
Numpy arrays!
Slicing of NumPy arrays:
Numpy arrays!
Get the shape of an Array
Numpy arrays!
Sorting NumPy Arrays:
Numpy arrays!
Sorting NumPy Arrays:
Activity!
● Slice the elements from index 2 to index 5
from end.
● (89, 84, 45, 58, 95, 222, 663)
Applications of NumPy!
What we learnt today!
● Basics of NumPy.
● Applications of NumPy.
Time for Feedback!
1. Click on the feedback form link.
2. Enter your personal details.
3. Rate the session based on
a. Overall Experience
b. Trainer
c. Content
4. Then click on Submit…!
Doubts?
Key Takeaways

What is your one key takeaway from the session?

You might also like