Spotify Dataset Analyse

We werken met een dataset genaamd spotify.csv, die informatie bevat over de meest gestreamde Spotify-songs van 2010 tot 2023. Het bestand is gedownload van Kaggle en bevat 10.440 records.

Hieronder de eerste regels van het bestand "spotify.csv".

schermafdruk csv
spotify.csv
Eerste lijnen in het bestand.

Beschrijving van de data

Databestand

Het bestand is beschikbaar in het working directory van Dodona. Om te debuggen in PyCharm of in een Jupyter Notebook) zal je het bestand moeten downloaden en bewaren in dezelfde map als je .py of .ipynb bestand.

Je kan het bestand hier downloaden:

Opgave

1. Functie get_data

Schrijf een functie get_data met de volgende parameters:

De functie doet het volgende:

Voorbeelden
>>> get_data(2023, 1000)
[('Miley Cyrus - Flowers', 'Pop'), ('Jung Kook - Seven', 'Pop'), ('Tate McRae - greedy', 'Pop'), ('Jimin - Like Crazy', 'Pop'), ('Eslabon Armado - Ella Baila Sola', 'World/Traditional'), ('David Kushner - Daylight', 'Pop'), ('Doja Cat - Paint The Town Red', 'Pop'), ('Mitski - My Love Mine All Mine', 'Indie/Alternative'), ('The Weeknd - One Of The Girls', 'R&B/Soul'), ('d4vd - Here With Me', 'Pop'), ('Yng Lvcas - La Bebe', 'World/Traditional'), ('KAROL G - TQG', 'World/Traditional'), ('Olivia Rodrigo - vampire', 'Pop'), ('Grupo Frontera - un x100to', 'World/Traditional'), ('Morgan Wallen - Last Night', 'World/Traditional')]


>>> get_data(2024, 1)
[]

      

2. Functie songcount

Schrijf een functie songcount met de volgende parameters:

De functie doet het volgende:

Voorbeelden
>>> songcount(2023, 200)
{'Pop': 106, 'World/Traditional': 105, 'Indie/Alternative': 2, 'R&B/Soul': 10, 'Hip-Hop/Rap': 62, 'Electronic/Dance': 13, 'Other': 1, 'Rock': 3, 'Classical/Orchestral': 1}
>>> songcount(2023)
{'Pop': 267, 'World/Traditional': 244, 'Indie/Alternative': 3, 'R&B/Soul': 19, 'Hip-Hop/Rap': 162, 'Electronic/Dance': 38, 'Other': 8, 'Rock': 10, 'Classical/Orchestral': 2, 'Metal': 5}
>>> songcount(2024, 1)
"Geen gegevens beschikbaar."