{"id":"code-work-teach-pandas-best-quiz-attempt","audience":"teachers","category":"coding","track":"coding","technique":"context","title":"Keep each student's best quiz attempt with pandas","free":false,"task":"Write a pandas script that reads quiz_export.csv and writes best_scores.csv with exactly two columns, email and best_pct, one row per student. Scores come in as text like 12/15, and retakes were out of 20, so turn each score into a percent (points divided by possible, times 100) before comparing. Match students by email lowercased, keep each one's highest percent rounded to 1 decimal, and don't write the index. One code block, at most 12 lines, then under 25 words outside the code.","materialLabel":"Quiz export, first rows (attached to your prompt automatically)","material":"quiz_export.csv - Unit 3 quiz, all attempts (from the quiz tool)\n\nemail,score,submitted_at,attempt\najones@stu.ridgeview.example,12/15,2026-10-20 09:14,1\nAJones@stu.ridgeview.example,17/20,2026-10-27 09:05,2\nblowe@stu.ridgeview.example,14/15,2026-10-20 09:16,1\ncmendes@stu.ridgeview.example,9/15,2026-10-20 09:20,1\ncmendes@stu.ridgeview.example,15/20,2026-10-27 09:11,2\n\nNotes from Ms. Adeyemi:\n- The retake had 5 extra questions, so it was out of 20.\n- Students could log in with different capitalization; the tool doesn't care.\n- I paste best_scores.csv into the gradebook, which expects those two column names.\n- About 28 students took it.\n- The quiz tool's own report only shows the latest attempt.","rules":[{"type":"codeBlocks","count":1},{"type":"maxCodeLines","max":12},{"type":"maxProseWords","max":25}],"mistakes":[{"title":"Not explaining the scores","why":"The AI compares raw points, so a 15/20 beats a 14/15.","fix":"Add: \"Turn 12/15 into a percent before comparing.\"","checks":["r0"]},{"title":"Not mentioning capital letters","why":"The AI treats AJones@ and ajones@ as two students.","fix":"Add: \"Match by email lowercased, keep the highest percent.\"","checks":["r1"]},{"title":"Leaving the output open","why":"The AI keeps extra columns or writes the index, so the gradebook paste breaks.","fix":"Add: \"Exactly email and best_pct, 1 decimal, index=False.\"","checks":["r2"]},{"title":"Getting a menu of options","why":"The AI likes to offer two or three versions of the script, so you're left to pick and test them yourself.","fix":"Add: \"Give one script only, in one code block, no alternatives.\"","checks":["codeBlocks","maxCodeLines"]},{"title":"Getting a tutorial","why":"By default the AI explains every part of the code at length, which you then have to scroll past.","fix":"Add: \"After the code, one line under 12 words. Nothing else.\"","checks":["maxProseWords"]}],"promptHints":[{"label":"Explains the score format","patterns":["12/15","out of","percent","divid"]},{"label":"Handles capital letters","patterns":["lower","capital"]},{"label":"Says which attempt to keep","patterns":["highest","best","max"]},{"label":"Sets the output","patterns":["best_pct","index=false","two columns"]},{"label":"Asks for one answer only","patterns":["\\b(one|single|1)\\s+(script|code block|block|version)","only one","no (alternatives|options|other versions)"]}],"hint":"The retake had a different number of questions. Tell the AI how to compare attempts fairly and what the output file must look like.","rubricLabels":["Turns the text score into a percent by splitting on / and dividing points by possible (times 100), so 17/20 becomes 85.0 and 12/15 becomes 80.0","Lowercases the email before grouping and keeps each student's highest percent (groupby email then max, or sort and drop_duplicates)","Writes best_scores.csv with exactly the columns email and best_pct, best_pct rounded to 1 decimal, and index=False"]}