0% found this document useful (0 votes)
25 views8 pages

Numpy

NumPy is a Python library that provides support for large, multi-dimensional arrays and matrices, along with high-level mathematical functions. It is more memory-efficient and faster than Python lists, allowing for element-wise operations and various mathematical methods. The document also covers practical applications, data types, and functions related to NumPy, including reshaping and indexing.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views8 pages

Numpy

NumPy is a Python library that provides support for large, multi-dimensional arrays and matrices, along with high-level mathematical functions. It is more memory-efficient and faster than Python lists, allowing for element-wise operations and various mathematical methods. The document also covers practical applications, data types, and functions related to NumPy, including reshaping and indexing.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

NUMPY & APPLICATIONS

i
INTRODUCTION TO NUMPY

NumPy is a library for the Python programming


language, adding support for large, multi-
dimensional arrays and matrices, along with a
large collection of high-level mathematical
functions to operate on these arrays.

LISTS VS NUMPY

Python Lists NumPy Arrays

 The list can be homogeneous or  Array are by default homogeneous


heterogeneous.

 Elements of an array are stored


 Elements of a list need not be contiguously in memory and memory
contiguous in memory. efficient

 Element wise operation is not possible  Element wise operation is possible

PYTHON LISTS VS NUMPY ARRAYS (DATA TYPES)

1
MEMORY ALLOCATION

ELEMENT WISE OPERATION

2
SOLD IN SHOP (IN KG)

APPLE BANANA ORANGE

20 22 35

• Bonus For The Employee

• Up To 10kg: No Bonus

• Above 10 Kgs, Each Kg Rs. 20

LISTS VS NUMPY-PRACTICALS
• Creation Of List And Data Type

• Creation Of Numpy Array And Data Type

• Different Ways Of Creating Numpy Arrays

• Checking Data Types (Python Lists Vs Numpy Arrays)

• Element Wise Operations

• Speed Check

NUMPY ADVANTAGES
• Consumes less memory.

• Very fast as compared to the python List.

• Many mathematical methods

NUMPY BASICS
 Numpy.Arange ()

 Numpy.Linspace()

 Numpy.Zeros()

 Numpy.Ones()

 Numpy.Full()

 Reshape

3
RESHAPE
Sales Input File Is Updated Column Wise Everyday (For One Week),
And Final File Look Like
Sales In Kgs

Monday Tuesday Wednesday Thursday Friday

Apple Banana Apple Banana Apple Banana Apple Banana Apple Banana

20 25 15 21 16 24 23 27 18 22

In similar lines for Price input file is updated column wise and final
file look like

Price in INR

Monday Tuesday Wednesday Thursday Friday

Apple Banana Apple Banana Apple Banana Apple Banana Apple Banana

200 30 180 32 175 35 220 36 210 32

Day wise (in rows) amount calculation

Fruit wise (in rows) amount calculation

4
INDEXING & SLICING AND FUNCTIONS
• Indexing & Slicing

• Basic Math Functions

• Linear Algebra Functions

• Aggregate Functions

AXIS (restricted to 2d arrays)

5
RESHAPE AND AXIS
Sales input file is updated column wise everyday (for one week), and
final file look like
Sales in Kgs

Monday Tuesday Wednesday Thursday Friday

Apple Banana Apple Banana Apple Banana Apple Banana Apple Banana

20 25 15 21 16 24 23 27 18 22

In similar lines for Price input file is updated column wise and final
file look like

Price in INR

Monday Tuesday Wednesday Thursday Friday

Apple Banana Apple Banana Apple Banana Apple Banana Apple Banana

200 30 180 32 175 35 220 36 210 32

Day wise (in rows) amount calculation

6
Fruit wise (in rows) amount calculation

BROADCAST

BROADCASTING

You might also like