Skip to Main Content
It looks like you're using Internet Explorer 11 or older. This website works best with modern browsers such as the latest versions of Chrome, Firefox, Safari, and Edge. If you continue with this browser, you may see unexpected results.

Python for Basic Data Analysis: NP.1 Introduction to NumPy

Get started on your learning journey towards data science using Python. Equip yourself with practical skills in Python programming for the purpose of basic data manipulation and analysis.

What is NumPy?

What is NumPy?

NumPy is one of the main libraries to use for scientific computing in Python. It allows you to work with high-performance multidimensional array objects and it also provides tools for working with these arrays. Arrays can have more than 3 dimensions but in this guide, we will only work with 2 dimensions.

2-dimensional arrays can be seen as matrices. This is a convenient way of storing and manipulating multivariate data with python.

What are arrays?

What are arrays?

An array is a grid of numeric data of the same type. Arrays come in different ranks, shapes and sizes. 

Rank

The number of dimensions in an array

Shape

The number of elements in each dimension of an array and is represented as a tuple

Size

The total number of elements in an array


Examples

Rank 1 array
This 1-dimensional array has 8 elements. Thus, its shape is the tuple (8,) and its size is 8. 

0

0

0

0

0

0

0

0


Rank 2 array
This 2-dimensional array, or a matrix, has 3 rows and 5 columns. Thus, its shape is the tuple (3,5) and its size is 15.

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0


We can create NumPy arrays from nested Python lists, and access the elements in the arrays using square brackets.

If you are curious about how data is arranged in NumPy and using reshape, check out this resource.


To get started we will first have to import the library:

Syntax

import numpy as np

Video Guides