Skip to learning content

DATA SCIENCE PYTHON PLAYGROUND

Data Foundations · A little practice goes a long way.

← Visualise lessonsTINY TABLES · REAL PYTHON · YOUR PACE
Optional · distribution detail · VR4 · 12 MIN

Review · distribution detail

Task 1 · Retrieve and combine

Exercises within this concept

  1. Task 1Retrieve and combineCurrent exercise
  2. Task 2Retrieve and combine
  3. Task 3Retrieve and combine
  4. Task 4Retrieve and combine
Task 1 · Board games

For df games lasting at least 20 minutes, inspect the distribution of minutes using a KDE with cut=0 and bw_adjust=1.

The editable setup on the right creates df. Run executes the setup and your work from top to bottom.

Your requirements

  1. Treat its shape as exploratory.
  2. Chart: title "Board games"; x "minutes"; y "Density".

Read the result: Would these few observations justify a claim about the population’s modes?

Your inputs

Board games · 6 synthetic rows
gamegenreminutesratingplayers
OrbitStrategy204.1Two
TilesPuzzle153.8Solo
QuestAdventure604.7Two
GroveStrategy354.4Solo
CastleAdventure454.5Two
CardsPuzzle103.6Solo

Revisit the concept lesson →

Remember the idea

Concept sketch: curve height = estimated densityDensitycurve height = estimated density

A kernel density estimate (KDE) smooths observations into a curve. Its height is density, not a count or a probability at one exact value.

A small example

Increasing bw_adjust from 1 to 2 makes bumps wider and the combined curve smoother; it does not add observations.

What each choice does
Code or choiceMeaning
bw_adjust=1Use the default smoothing bandwidth. Larger values smooth more; smaller values reveal more bumps.
cut=0Stop drawing at the observed minimum and maximum.
sns.kdeplot(..., x="value", ax=ax)Draw a smoothed view of a numeric column.
Hint

Choose the observations first, then map the requested measurements to the chart.

Reveal solution

One way to do it. Keep any supplied setup in the editor and use this in the Your work section.

import matplotlib.pyplot as plt
import seaborn as sns

fig, ax = plt.subplots(figsize=(6, 4))
selected = df[df["minutes"] >= 20]
sns.kdeplot(data=selected, x="minutes", cut=0, bw_adjust=1, ax=ax)
ax.set(title="Board games", xlabel="minutes", ylabel="Density")
fig.tight_layout()
plt.show()
Your task · Task 1
  1. For df games lasting at least 20 minutes, inspect the distribution of minutes using a KDE with cut=0 and bw_adjust=1.
  2. Treat its shape as exploratory.
  3. Chart: title "Board games"; x "minutes"; y "Density".

Tab: indent · Shift+Tab: outdent · Esc, then Tab: leave editor

Edit Python. Control or Command plus Enter runs it. Tab indents by four spaces. Shift plus Tab outdents. Press Escape, then Tab or Shift plus Tab to leave the editor.

Each run executes all editor code in a fresh Python session. Display charts with plt.show().

Python starts when you open a lesson.

Output

Run your code to see what Python returns.