Python Libraries : Numpy
Agenda
• Basics of NumPy
• Creating NumPy arrays and Matrices
• NumPy Functions
What is NumPy?
• It’s a Python package that stands for ‘Numerical Python’.
• It is the core library for scientific computing
• NumPy arrays provide tools for integrating C, C++, etc.
• Also useful in linear algebra, random number capability etc.
• NumPy array can also be used as an efficient
multi-dimensional container for generic data.
How do I install NumPy?
• From command prompt and type “pip
install numpy”.
• Once the installation is completed, and
simply import it by typing:
“import numpy as np”
Python NumPy
• Numpy array is a powerful N-dimensional array object
which is in the form of rows and columns.
• Array is a table of elements (usually numbers), all of the
same type, indexed by a tuple of positive integers.
• Number of dimensions of the array is called rank of the
array.
• A tuple of integers giving the size of the array along each
dimension is known as shape of the array.
Creating NumPy Array:
Transforming List into Numpy Array
One- Dimensional Numpy Array:
We can think of a one-dimensional array as a column
or a row of a table with one or more elements.
Two-Dimensional NumPy Array
A multidimensional array has more than one column.
We can consider a multi-dimensional array to be an
Excel Spreadsheet — it has columns and rows. Each
column can be considered as a dimension.
Three- Dimensional Array
• This will create 3 arrays with 4 rows and 5 columns each with
random integers.
3DArray = np.random.randint(10,
3DArray = np.random.randint(10,size=(3,
size=(3,4,
4, 5))
5))
• There are also other types available such as:
• Boolean
• Integer (signed and unsigned)
• Float
• Complex
Question 1- What is NumPy?
Question 2- How do I install NumPy?
Question 3- What is NumPy array?
Question 4- How many types of Numpy Array
we can create?
Question 5- How to create a Two -
Dimensional Array?