Numpy 1 7
Numpy 1 7
Numpy
Instructor:
Sayed Shahid Hussain
Research Associate,
AI in Healthcare, National Center of AI
UET Peshawar
Email: [email protected]
NumPy Introduction
NumPy
• NumPy stands for Numerical Python.
• NumPy is a Python library used for working with arrays.
• It also has functions for working in domain of linear algebra, fourier transform, and
matrices.
• NumPy aims to provide an array object that is up to 50x faster than traditional Python
lists.
• NumPy was created in 2005 by Travis Oliphant. It is an open source project and you
can use it freely.
Installation of NumPy
• If you have Python and PIP already installed on a system, then installation of NumPy is
very easy.
• Install it using this command:
• C:\Users\Your Name>pip install numpy
Import NumPy:
• Once NumPy is installed, import it in your applications by adding the import keyword:
NumPy Creating Arrays
• NumPy is used to work with arrays. The array object in NumPy is called
ndarray.
• To create an ndarray, we can pass a list, tuple or any array-like object into
the array() method, and it will be converted into an ndarray
Dimensions in Arrays
• A dimension in arrays is one level of array depth
Access Array Elements & Slicing
• NumPy arrays have an attribute called shape that returns a tuple with each
index having the number of corresponding elements.
• The function nditer() is a helping function that can be used from very basic
to very advanced iterations.