The question
An attendance upload may contain repeated submissions. Prepare the evidence without deleting any records.
df Duplicate evidenceYour inputs
df
submission_id identifies one submission. Identical IDs are repeated uploads. Do not remove or change source records.
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.
submission_id | student | group | hours | score | attended | date |
|---|---|---|---|---|---|---|
| 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 | 90 | true | 2026-04-02 |
| S005 | Learner 5 | A | 4 | 72 | false | 2026-04-03 |
View all 16 rows
submission_id | student | group | hours | score | attended | date |
|---|---|---|---|---|---|---|
| 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 | 90 | 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 |
| S004 | Learner 4 | B | 7 | 90 | true | 2026-04-02 |
| S014 | Learner 14 | B | 6 | 86 | true | 2026-04-07 |
| S009 | Learner 9 | A | 2 | 56 | false | 2026-04-05 |
| S016 | Learner 16 | B | 1 | 50 | true | 2026-04-08 |
The editable setup in Your Python creates these inputs when you run it.
An attendance upload may contain repeated submissions. Prepare the evidence without deleting any records.
repeatedDataFramerepeated_idsnumberDeliverables
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.
- Every repeated memberOutput
repeatedDataFrame- Create
repeatedwith every row whosesubmission_idappears more than once, including the first occurrence. - Keep all columns and source order.
- Create
- Affected submissionsOutput
repeated_idsnumber- Store the number of distinct
submission_idvalues inrepeated_ids.
- Store the number of distinct
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 flagging only later copies show the whole investigation?
Hint 2 — Tools
duplicated(), nunique() and boolean selection
Revisit: Find duplicate rows · What values exist?
Hint 3 — Approach
Find every member of repeated submission IDs, retain their full records, then count distinct affected IDs.
Explained solution
Add these lines below # Your work in the editor. The supplied input setup is already there.
repeated = df[df.duplicated(subset=['submission_id'], keep=False)]
repeated_ids = repeated.submission_id.nunique()
repeatedView supplied setup
This code is already at the top of the editor.
import pandas as pd
# Supplied input: df (16 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, 90, 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'),
('S004', 'Learner 4', 'B', 7, 90, True, '2026-04-02'),
('S014', 'Learner 14', 'B', 6, 86, True, '2026-04-07'),
('S009', 'Learner 9', 'A', 2, 56, False, '2026-04-05'),
('S016', 'Learner 16', 'B', 1, 50, True, '2026-04-08'),
],
columns=['submission_id', 'student', 'group', 'hours', 'score', 'attended', 'date'],
)Why these steps exist
- keep=False marks the first upload as well as later copies, so the investigation can compare every member.
- Distinct repeated IDs count affected submissions; counting rows would count their copies too.
Another valid approach
Use duplicate membership with all copies included; inspecting only later copies misses part of the evidence.