Table of Contents
ToggleData Science involves analyzing and interpreting datasets using various mathematical and statistical methods. This guide explains three essential Python functions for data analysis: max(), min(), and mean(). These functions help identify maximum, minimum, and average values within datasets.
Below is an example dataset from a sports watch, including six key metrics such as duration of training, heart rate, calorie burn, and more. This dataset is commonly used in health and fitness data analysis.
| Duration (minutes) | Average Pulse (BPM) | Max Pulse (BPM) | Calorie Burnage (kcal) | Hours Worked | Hours Slept |
|---|---|---|---|---|---|
| 30 | 80 | 120 | 240 | 10 | 7 |
| 30 | 85 | 120 | 250 | 10 | 7 |
| 45 | 90 | 130 | 260 | 8 | 7 |
| 45 | 95 | 130 | 270 | 8 | 7 |
| 60 | 105 | 140 | 290 | 7 | 8 |
Note: The column names use underscores (_) to separate words for better compatibility in Python.
In this tutorial, we will explore three fundamental Python functions frequently used in data analysis: max(), min(), and mean(). These functions help find maximum, minimum, and average values within datasets, enabling efficient data insights.
max() Function
The Python max() function identifies the highest value in an array or list. This function is ideal for determining maximum values in a dataset.
Average_pulse_max = max(80, 85, 90, 95, 100, 105, 110, 115, 120, 125)
print(Average_pulse_max)
min() Function
The Python min() function finds the smallest value in an array or list. It is a quick way to determine the minimum value in a dataset.
Average_pulse_min = min(80, 85, 90, 95, 100, 105, 110, 115, 120, 125)
print(Average_pulse_min)
mean() Function
The mean() function from the NumPy library calculates the average value of an array. This is commonly used in data science for summarizing datasets.
import numpy as np
Calorie_burnage = [240, 250, 260, 270, 280, 290, 300, 310, 320, 330]
Average_calorie_burnage = np.mean(Calorie_burnage)
print(Average_calorie_burnage)
Note: The prefix np. in np.mean specifies that the function is from the NumPy library.
