top of page
What is Numpy?

NumPy is the fundamental library for scientific computing, data manipulation and machine learning in Python.

It is used for fast operations on arrays, including mathematical, logical, shape manipulation, sorting, selecting, I/O, discrete Fourier transforms, basic linear algebra, basic statistical operations, random simulation and much more.

Numpy stands for Numerical Python. Pronounced as Num-pie

Its developed by Travis Oliphant in 2006. Written in Python and C-Language.

numpy.png

Storage of Array

Elements of array are stored in contiguous memory location i.e. stores all elements of array in continuous memory either it is one dimensional array or multi dimensional array.

numparr2.PNG

It stores firstly, the first row, then second row, then third row and so forth...

Row Major Form

It stores firstly, the first column, then second column, then third column and so forth…

Column Major Form
Installation of NumPy
Importing Python
numpyarr3.PNG
Windows:-
pip install numpy
Linux:-
$ sudo apt install python-numpy

Installation of numpy can be done in various ways. If you are using Anaconda, then it installed automatically. Otherwise you have to install it separately by using pip

Open shell in linux or command prompt in windows. 

Before going to use NumPy, you need to import python. import command can be used for importing python package. First run the python interpreter and then type 

c:\>python   # to start python interpreter
>>> import numpy
>>> import numpy as np
NumPy Array Terminology
numpyarr4.PNG

NumPy array is also called N-dimensional NumPy data array i.e. ndarray.

Axes –    Dimensions of NumPy array is referred as axes. Axes are always numbered 0 onwards for ndarrays.

Rank –  It means number of axes in an ndarray.

Shape – It means size of array i.e. number of elements along each axis.

Data type (dType) – tells about the type of data. Default data  type of ndarray is  float.

Itemsize – refers to the size of each element of an ndarray in  bytes.

NumPy Array Data Types
numpyarr5.PNG
numpyarr6.PNG
What is Numpy?
What is Array?
Storage of Array
Installation of Numpy
Numpy Terminology
Numpy Data Types
Numpy Array vs List
What is Array?
Types of Array

In general, Array refers to a named group of homogeneous elements.

A NumPy array is simply a grid that contains values of the same/homogeneous type.

There are two types of array-

  1. One Dimensional Array

  • having single row/column

  • known as Vectors

  • set of elements having same data type.

  2. Multi Dimensional Array

  • having multiple rows and columns.

  • known as Matrix

  • set of elements having same data type.

numpyarr.PNG
NumPy Array vs List
  • The NumPy array elements are also indexed in memory in the same manner  as list’s elements.

Forward Indexing : 

  0 , 1, 2, 3, 4 …

Backwarkd Indexing :

  … -4, -3, -2, -1

  • NumPy array size & List size can be changed.

  • NumPy array contain homogenous types, while List can contain mixed.

  • Equivalent NumPy array cosumed less space.

  • NumPy array support vectorized operation, while List does not.

  • Numpy array is faster than Python List.

  • Numpy array consume less memory.

  • Numpy array is very convenient while performing element-wise operation.

bottom of page