bugl
bugl
HomeLearnPatternsPathsSearch
HomeLearnPatternsPathsSearch

Loading lesson path

Learn/Data Science/Data Science
Data Science•Data Science

Data Science Functions

Flash cards

Review the key moves

1/4
Core idea

What is the main idea behind Data Science Functions?

Lesson checks

Practice each idea before moving on

Short Mimo-style checks built from this lesson's code, terms, and sequence.

1Quick choice

Which statement best captures the main point of this lesson?

2Fill blank

Complete the missing token from the example code.

___ = max(80, 85, 90, 95, 100, 105, 110, 115, 120, 125)
3Order

Put the learning moves in the order that makes the concept easiest to apply.

The max() function
The Sports Watch Data Set
Data Science Functions
4Data move

Before charting or modeling a dataset, which move should come first?

This chapter shows three commonly used functions when working with Data Science: max(), min(), and mean().

The Sports Watch Data Set

DurationAverage_PulseMax_PulseCalorie_BurnageHours_WorkHours_Sleep
3080120240107
3085120250107
459013026087
459513027087
4510014028007
6010514029078
6011014530078
6011514531088
7512015032008
7512515033088

The data set above consists of 6 variables, each with 10 observations:

  • Duration - How long lasted the training session in minutes?
  • Average_Pulse - What was the average pulse of the training session? This is measured by beats per minute
  • Max_Pulse - What was the max pulse of the training session?
  • Calorie_Burnage - How much calories were burnt on the training session?
  • Hours_Work - How many hours did we work at our job before the training session?
  • Hours_Sleep - How much did we sleep the night before the training session?

We use underscore (_) to separate strings because Python cannot read space as separator.

The max() function

The Python max() function is used to find the highest value in an array.

Example

Average_pulse_max = max(80, 85, 90, 95, 100, 105, 110, 115, 120, 125)
print
(Average_pulse_max)

The min() function

The Python min() function is used to find the lowest value in an array.

Example

Average_pulse_min = min(80, 85, 90, 95, 100, 105, 110, 115, 120, 125)
print
(Average_pulse_min)

The mean() function

The NumPy mean() function is used to find the average value of an array.

Example

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

We write np. in front of mean to let Python know that we want to activate the mean function from the Numpy library.

Previous

Data Science - Python DataFrame

Next

Data Science - Data Preparation