0% found this document useful (0 votes)
26 views18 pages

Workshop 2 - NumPy

This document discusses NumPy, a Python library used for working with multidimensional arrays and matrices for numerical computing. It covers how to install NumPy, the main attributes of NumPy arrays, different ways to initialize arrays like empty(), ones(), zeros(), and full(), shape manipulation functions like ravel, T, reshape and resize, and some useful NumPy functions like sum(), max(), min(), argmin(), and argmax().

Uploaded by

Utkarsh Pandey
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)
26 views18 pages

Workshop 2 - NumPy

This document discusses NumPy, a Python library used for working with multidimensional arrays and matrices for numerical computing. It covers how to install NumPy, the main attributes of NumPy arrays, different ways to initialize arrays like empty(), ones(), zeros(), and full(), shape manipulation functions like ravel, T, reshape and resize, and some useful NumPy functions like sum(), max(), min(), argmin(), and argmax().

Uploaded by

Utkarsh Pandey
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/ 18

NUMPY

Workshop
iMAZE
● Python has no 2d arrays (realistically), so we have NumPy
● Numpy is efficient, and fast.
● Numpy uses relatively less memory to store data.
● NumPy is suited for Image processing, signal processing, machine learning
and a lot of other great stuff
How to Install NumPy
● Open cmd with administrator
privileges.
● Type pip install numpy.
Arrays In NumPy
● NumPy’s array class is called ndarray. Also known as alias array.

Main Attributes:
● ndarray.ndim : the number of axes (dimensions) of the array.
● ndarray.shape : the dimensions of the array.
● ndarray.size : the total number of elements of the array. This is equal to the
product of the elements of shape.
● ndarray.dtype : an object describing the type of the elements in the array
Initializing Arrays
● empty() : Return a new array of given shape and type, without initializing
entries.
● eye(): Return a 2-D array with ones on the diagonal and zeros elsewhere.
● identity(): Return the identity array.
● ones(): Return a new array of given shape and type, filled with ones.
● zeros(): Return a new array of given shape and type, filled with zeros.
● full(): Return a new array of given shape and type, filled with fill_value.
Shape Manipulation

● ndarray.ravel

● ndarray.T

● ndarray.reshape

● ndarray.resize
For Example
● The reshape function returns its argument with a modified shape, whereas
the ndarray.resize method modifies the array itself:
Some Useful Functions

● np.sum( ) : Returns the sum of items of array

● np.max( ) : Returns the maximum value

● np.min( ) : Returns the minimum value

● np.argmin( ): Returns the index of minimum value.

● np.argmax( ): Returns the index of maximum value.


Some Useful Functions

● np.nonzero( ) : Returns the indices of non-zero elements

of array.

You might also like