Learn practical skills, build real-world projects, and advance your career

Last.FM Example

Author: Andreas Traut

In this example I downloaded my complete history of played songs since 2016 from www.last.fm (66'955 songs in total) and re-built some of these nice statistics and figues, which last.fm provides. This are for example a bar-plot with monthly aggregates of total played songs. Or top 10 songs of the week and so on. Having the same plots at the end as last.fm has prooves, that my results are correct. :-)

The format of the csv-file is as follows:

Daniel Santacruz		Lento	06.02.2020 16:45
Mau y Ricky	Para Aventuras y Curiosidades	Mi Mala	06.02.2020 16:27
Nelson Freitas	Elevate	Something Good	06.02.2020 16:23
Jennifer Dias	Love U	Love U	06.02.2020 16:22
Nelson Freitas	Sempre Verão	Every Day All Day	06.02.2020 16:18
Daniel Santacruz	Lento	Lento	06.02.2020 16:16
Mogli	Wanderer (Expedition Happiness Soundtrack)	Road Holes	05.02.2020 15:49
Serena Ryder	Harmony (Deluxe)	For You	04.02.2020 17:36
Y'akoto	Perfect Timing	Perfect Timing	04.02.2020 17:32
Awa Ly	FIVE AND A FEATHER	LET ME LOVE YOU	04.02.2020 17:28
Doris Day	Top 100 Jazz	Cheek to Cheek	04.02.2020 17:24
Kendra Morris	Summertime	Summertime	04.02.2020 17:22
import pandas as pd
import numpy as np
from matplotlib import pyplot
df = pd.read_csv('lastfm_data.csv', 
                 names=['artist', 'album', 'song', 'timestamp'], 
                 converters={'timestamp':pd.to_datetime})
df.head()