Practice / strings dates nulls

Plays Per Month

medium

Waveform wants monthly engagement numbers.

plays

played_at is a date stored as a yyyy-MM-dd string; assume all data is from the same year.

Your task: return one row per month (as an integer 112) with a column num_plays counting the plays in that month.

Assign your answer DataFrame to result. Row order doesn't matter.

playsinput DataFrame

Schema
columntype
play_idlong
played_atstring
Sample rows
play_idplayed_at
12026-06-03
22026-06-21
32026-07-01
42026-07-15
52026-07-30
62026-08-02
Expected output shape
monthnum_plays· 3 rows
Hint

Parse the string with F.to_date("played_at", "yyyy-MM-dd"), extract F.month(...) as an integer, then groupBy("month") and count("*").

Lesson refresher

This problem builds on Strings, Dates & Nulls (~8 min). Pop it open in a new tab if you want a quick recap.

Loading editor…
Hit Run to execute your code and see the output here.