View Source On this day ♫
Mix.install(
[{:coda, "~> 0.3"}, {:kino_explorer, "~> 0.1.8"}],
config: [
lastfm_archive: [
data_dir: "./lastfm_data/",
user: ""
]
]
)
alias Coda.OnThisDay
alias Explorer.DataFrame
alias Coda.Analytics.OnThisDay, as: OTDA
# try/rescue until LastfmArchive returns error tuples
{scrobbles_df, new_facets_on_this_day_dfs, news_artists, new_albums, new_tracks} =
try do
{df, dfs} = {OTDA.dataframe(), OTDA.new_facet_dataframes(format: :ipc_stream)}
{df, dfs, dfs[:artists], dfs[:albums], dfs[:tracks]}
rescue
_error -> {nil, nil, nil, nil, nil}
end
:ok
Introduction
Analytics of all the music played on this day, today in this past. This Livebook is based on data created by lastfm_archive.
Prerequisites
- Setup, installation
- Columnar data transforms: transform archive into Apache Arrow format (
format: :ipc_stream
option) - Facets archiving (optional): create
artists
,albums
,tracks
archives, for theFor the first time
section
Overview
See a sample output.
{scrobbles_df, new_facets_on_this_day_dfs} |> OnThisDay.render_overview()
Most played
The following are most played artists
, albums
and tracks
on this day by play counts and frequencies across the years. Samples of play onced facets are also listed.
See a sample output.
scrobbles_df |> OnThisDay.render_most_played()
For the very first time..
What music did you discover on this day and which year? The following analytics show various debut facets in your Lastfm listening history, top artists
, albums
and tracks
scrobbled for the very first time.
The counts = total playcounts of tracks etc. within the entire listening history.
See a sample output.
new_facets_on_this_day_dfs |> OnThisDay.render_new_on_this_day(scrobbles_df)
Explore most played data
In due course, further analytics and visualisation will be presented. These include newly discovered and most frequently played music on this day over the years. Meanwhile you can interactively delve into the data using Kino explorer below.
require Explorer.DataFrame
scrobbles_df
|> DataFrame.lazy()
|> DataFrame.group_by(["track", "album"])
|> DataFrame.summarise(datetime_count: count(datetime))
|> DataFrame.arrange(desc: datetime_count)
|> DataFrame.collect()
Explore new facets data
require Explorer.DataFrame
news_artists |> DataFrame.lazy() |> DataFrame.group_by("artist") |> DataFrame.collect()
new_albums |> DataFrame.lazy() |> DataFrame.group_by("album") |> DataFrame.collect()
new_tracks
|> DataFrame.lazy()
|> DataFrame.group_by(["track", "album", "artist"])
|> DataFrame.collect()