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.

Math with NumPy II

When conducting an analysis, we often need to find the mean, standard deviation and minimum/maximum values.

Let's start with a 2D array, which is the most common for data analysis.
 

Simple math required for data analysis

Mean

Use .mean to find the mean of elements in an array. You can find the mean of all elements, or find the mean of elements in rows or columns by specifying the axis. 


Now let's verify the information above:

Sum

Use np.sum to sum all elements in the matrix. You can also specify the axis to sum by rows or columns. 

Standard deviation

Use np.std to find the standard deviation of all elements in the matrix. You can also specify the axis to find the standard deviation of rows or columns.

Minimum and maximum value of the array

Use .min and .max to find the minimum and maximum of the entire matrix. You can also specify the axis for rows and columns.

Video Guide

Exercises

Use this array for the following practice: 

myArray = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])


1. Find the mean of this array

2. Find the standard deviation by rows

3. Find the maximum value in the array