Skip to learning content

DATA SCIENCE PYTHON PLAYGROUND

Data Foundations

← All challenges
VC06 · Student attendance / study · ~10–20 min

Show a small sample honestly

population · variation · transparency

Individual observations

The question

Show every attending learner’s score so a small sample is not hidden behind a summary.

df Individual observations

Your inputs

df

One row is one learner’s submission. Use attendance and score availability; missing study hours do not disqualify a score.

Field meanings and units
submission_id
Attendance-submission identifier.
student
Learner label.
group
Comparison group.
hours
Study duration in hours.
score
Assessment score in points.
attended
Whether the learner attended.
date
Calendar date supplied as YYYY-MM-DD text unless the task states it is invalid.
df · first 5 of 12 rows
submission_idstudentgrouphoursscoreattendeddate
S001Learner 1A255false2026-04-01
S002Learner 2B578true2026-04-01
S003Learner 3A368true2026-04-02
S004Learner 4B7Nonetrue2026-04-02
S005Learner 5A472false2026-04-03
View all 12 rows
df · complete input
submission_idstudentgrouphoursscoreattendeddate
S001Learner 1A255false2026-04-01
S002Learner 2B578true2026-04-01
S003Learner 3A368true2026-04-02
S004Learner 4B7Nonetrue2026-04-02
S005Learner 5A472false2026-04-03
S006Learner 6B685true2026-04-03
S007Learner 7A894true2026-04-04
S008Learner 8B149true2026-04-04
S009Learner 9A256false2026-04-05
S010Learner 10B579true2026-04-05
S011Learner 11A369true2026-04-06
S012Learner 12B791true2026-04-06

The editable setup in Your Python creates these inputs when you run it.

Your task · Show a small sample honestly

Show every attending learner’s score so a small sample is not hidden behind a summary.

observationsDataFramefigFigure

Deliverables

Make the outputs listed below. Use each name exactly as shown. Then choose Check answer.

Python name key

Teal outlines name table columns. Violet left rules name Python objects. Dotted rules mark syntax, functions and parameters. Use each name exactly as shown.

Words in this task
eligible
rows that meet this task’s stated conditions
  1. Attending learnersOutputobservationsDataFrame
    1. Create observations with group and score for attended=True and known score, keeping source order.
  2. FigureOutputfigFigure
    1. Create fig showing every eligible score as a point within its group.
    2. Put groups on the horizontal axis and scores on the vertical axis; modest sideways jitter is optional.
    3. Add a meaningful title and labels
    4. Display the figure.

    Identify Group and Score on the appropriate axes; extra wording is welcome.

Data policy Keep all supplied source tables unchanged. Work on separate outputs.

Help Hints & explained solution

Choose the amount of help you need. Opening one hint does not reveal the others.

Hint 1 — Think

Would a single average make the individual observations visible?

Hint 2 — Tools

Boolean selection and sns.stripplot() or Axes.scatter()

Revisit: Combine conditions · Raw points · Finish a chart properly

Hint 3 — Approach

Select the requested learners and show each score at its group position without summarising away observations.

Explained solution

Add these lines below # Your work in the editor. The supplied input setup is already there.

observations = df.loc[df.attended & df.score.notna(), ['group', 'score']]
fig, ax = plt.subplots()
sns.stripplot(
    data=observations, x='group', y='score', jitter=False, ax=ax
)
ax.set(title='Attending learner scores', xlabel='Group', ylabel='Score')
fig.tight_layout()
plt.show()
View supplied setup

This code is already at the top of the editor.

import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

# Supplied input: df (12 rows)
df = pd.DataFrame(
    [
        ('S001', 'Learner 1', 'A', 2, 55, False, '2026-04-01'),
        ('S002', 'Learner 2', 'B', 5, 78, True, '2026-04-01'),
        ('S003', 'Learner 3', 'A', 3, 68, True, '2026-04-02'),
        ('S004', 'Learner 4', 'B', 7, None, True, '2026-04-02'),
        ('S005', 'Learner 5', 'A', 4, 72, False, '2026-04-03'),
        ('S006', 'Learner 6', 'B', 6, 85, True, '2026-04-03'),
        ('S007', 'Learner 7', 'A', 8, 94, True, '2026-04-04'),
        ('S008', 'Learner 8', 'B', 1, 49, True, '2026-04-04'),
        ('S009', 'Learner 9', 'A', 2, 56, False, '2026-04-05'),
        ('S010', 'Learner 10', 'B', 5, 79, True, '2026-04-05'),
        ('S011', 'Learner 11', 'A', 3, 69, True, '2026-04-06'),
        ('S012', 'Learner 12', 'B', 7, 91, True, '2026-04-06'),
    ],
    columns=['submission_id', 'student', 'group', 'hours', 'score', 'attended', 'date'],
)

Why these steps exist

  • Attendance and a known score define the population. Other missing fields are irrelevant.
  • Each mark is one score. Sideways jitter can reduce overlap without changing any score or group.

Another valid approach

Unjittered or modestly jittered points are accepted; the measured score and group membership must not change.

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. Named outputs appear below when you run. Display charts with plt.show().

Python starts when you open a lesson.

Output

Run your code to see what Python returns.