Skip to Main Content

Python for Basic Data Analysis

Start your data science journey with Python. Learn practical Python programming skills for 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