History of lastfm_360k
The changes to the source code of this entry in the repository, newest first, each with the differences it made to the entry's files. They are also listed on GitLab.
[entries] Add the date when each entry was added, and remove icon_hash beff7c9
The dates are those of the commits that first added the entries' files (2020-08-11 for the entries of the initial commit); renamed entries keep the date of their first name. Changed: none
diff --git a/entries/lastfm_360k/__init__.py b/entries/lastfm_360k/__init__.py
index f29a15f..b5668bb 100644
--- a/entries/lastfm_360k/__init__.py
+++ b/entries/lastfm_360k/__init__.py
@@ -38,7 +38,7 @@ The network has the following properties:
tags = ['Social', 'Online', 'Preferences', 'Bipartite', 'Weighted', 'Metadata']
url = 'https://www.upf.edu/web/mtg/lastfm360k'
citation = [('Ò. Celma, "Music Recommendation and Discovery: The Long Tail, Long Fail, and Long Play in the Digital Music Space." Springer (2010)', 'https://doi.org/10.1007/978-3-642-13287-2')]
-icon_hash = None
+date_added = '2026-10-28'
upstream_license = ("Non-commercial use (distributed with permission of Last.fm)", "https://www.upf.edu/web/mtg/lastfm360k")
# the server refuses non-browser user agents (open_url() falls back to one)
upstream_prefix = 'http://mtg.upf.edu/static/datasets/last.fm'
[entries] Prefix the properties in the descriptions with (Node), (Edge) or (Graph) bc3dbbd
The lists of properties at the end of the descriptions marked edge properties with "Edge" but left node properties unmarked, or grouped them in "Nodes: `a`, ...; `b`, ..." items, so the kind of a property was often unclear. Every item now starts with (Node), (Edge) or (Graph), followed by the property names, a colon and the explanation, one item per property or group of properties; qualifications (kinds of nodes, networks) follow the names in parentheses. Properties that were only named got a short explanation, and a few items that named the wrong kind of property were corrected.
diff --git a/entries/lastfm_360k/__init__.py b/entries/lastfm_360k/__init__.py
index d8315de..f29a15f 100644
--- a/entries/lastfm_360k/__init__.py
+++ b/entries/lastfm_360k/__init__.py
@@ -27,14 +27,14 @@ The artists are identified by their MusicBrainz identifiers (MBID), or, for the
The network has the following properties:
-- `name`: the anonymous identifier of the user (a SHA-1 hash), or the name of the artist.
-- `is_user`: whether the node is a user (otherwise an artist).
-- `mbid`: the MusicBrainz identifier of the artist (empty for users and for artists without one).
-- `gender`: the gender of the user (`m`, `f`, or empty if not given; empty for artists).
-- `age`: the age of the user (-1 if not given, and for artists).
-- `country`: the country of the user (empty if not given, and for artists).
-- `signup`: the date of registration of the user, in Unix time (-1 if not given, and for artists).
-- Edge `weight`: the number of plays of the artist by the user."""
+- (Node) `name`: the anonymous identifier of the user (a SHA-1 hash), or the name of the artist.
+- (Node) `is_user`: whether the node is a user (otherwise an artist).
+- (Node) `mbid`: the MusicBrainz identifier of the artist (empty for users and for artists without one).
+- (Node) `gender`: the gender of the user (`m`, `f`, or empty if not given; empty for artists).
+- (Node) `age`: the age of the user (-1 if not given, and for artists).
+- (Node) `country`: the country of the user (empty if not given, and for artists).
+- (Node) `signup`: the date of registration of the user, in Unix time (-1 if not given, and for artists).
+- (Edge) `weight`: the number of plays of the artist by the user."""
tags = ['Social', 'Online', 'Preferences', 'Bipartite', 'Weighted', 'Metadata']
url = 'https://www.upf.edu/web/mtg/lastfm360k'
citation = [('Ò. Celma, "Music Recommendation and Discovery: The Long Tail, Long Fail, and Long Play in the Digital Music Space." Springer (2010)', 'https://doi.org/10.1007/978-3-642-13287-2')]
[entries] Remove unneeded code from the entries 2c69f19
Unneeded "global files" statements, unused imports and variables, f-strings without placeholders, duplicate keys in foodweb_little_rock (keeping the order and the values used), and the second definition of get_lines() in twitter_higgs. Nothing changes in the networks or descriptions. Changed: none
diff --git a/entries/lastfm_360k/__init__.py b/entries/lastfm_360k/__init__.py
index 8dad5c6..d8315de 100644
--- a/entries/lastfm_360k/__init__.py
+++ b/entries/lastfm_360k/__init__.py
@@ -58,7 +58,6 @@ _MONTHS = {m: i + 1 for i, m in enumerate(["Jan", "Feb", "Mar", "Apr", "May",
@coerce_props()
@annotate()
def parse(alts=None):
- global files
name = __name__.split(".")[-1]
for fnames, alt, fmt in files:
if alts is not None and alt not in alts:
[entries] New entry: lastfm_360k 8a9ea75
diff --git a/entries/lastfm_360k/__init__.py b/entries/lastfm_360k/__init__.py
new file mode 100644
index 0000000..8dad5c6
--- /dev/null
+++ b/entries/lastfm_360k/__init__.py
@@ -0,0 +1,122 @@
+#! /usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2026 Tiago de Paula Peixoto <tiago@skewed.de>
+#
+# This program is free software: you can redistribute it and/or modify it under
+# the terms of the GNU Affero General Public License as published by the Free
+# Software Foundation, either version 3 of the License, or (at your option) any
+# later version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
+# details.
+#
+# You should have received a copy of the GNU Affero General Public License along
+# with this program. If not, see <http://www.gnu.org/licenses/>.
+
+import calendar
+
+from .. import *
+
+title = "Last.fm users and their top artists (2008)"
+description = r"""A bipartite network of the users of the music website Last.fm and the artists they listened to, collected by Òscar Celma in 2008 through the Last.fm API. For each of about 360,000 users, the data give the artists most listened to by the user (up to about 50), with the number of plays of each. Each node is a user or an artist, and an edge connects a user to an artist among the user's top artists, weighted by the number of plays.
+
+The artists are identified by their MusicBrainz identifiers (MBID), or, for the artists without one, by their names as given (so that the same artist may appear under different spellings, and several artists with the same name are merged). An artist with an MBID that appears with several names is named after its first occurrence.
+
+The network has the following properties:
+
+- `name`: the anonymous identifier of the user (a SHA-1 hash), or the name of the artist.
+- `is_user`: whether the node is a user (otherwise an artist).
+- `mbid`: the MusicBrainz identifier of the artist (empty for users and for artists without one).
+- `gender`: the gender of the user (`m`, `f`, or empty if not given; empty for artists).
+- `age`: the age of the user (-1 if not given, and for artists).
+- `country`: the country of the user (empty if not given, and for artists).
+- `signup`: the date of registration of the user, in Unix time (-1 if not given, and for artists).
+- Edge `weight`: the number of plays of the artist by the user."""
+tags = ['Social', 'Online', 'Preferences', 'Bipartite', 'Weighted', 'Metadata']
+url = 'https://www.upf.edu/web/mtg/lastfm360k'
+citation = [('Ò. Celma, "Music Recommendation and Discovery: The Long Tail, Long Fail, and Long Play in the Digital Music Space." Springer (2010)', 'https://doi.org/10.1007/978-3-642-13287-2')]
+icon_hash = None
+upstream_license = ("Non-commercial use (distributed with permission of Last.fm)", "https://www.upf.edu/web/mtg/lastfm360k")
+# the server refuses non-browser user agents (open_url() falls back to one)
+upstream_prefix = 'http://mtg.upf.edu/static/datasets/last.fm'
+_d = 'lastfm-dataset-360K.tar.gz:lastfm-dataset-360K'
+files = [((f'{_d}/usersha1-artmbid-artname-plays.tsv',
+ f'{_d}/usersha1-profile.tsv'), None, None)]
+
+def fetch_upstream(force=False):
+ return fetch_upstream_files(__name__.split(".")[-1], upstream_prefix, files,
+ force)
+
+_MONTHS = {m: i + 1 for i, m in enumerate(["Jan", "Feb", "Mar", "Apr", "May",
+ "Jun", "Jul", "Aug", "Sep", "Oct",
+ "Nov", "Dec"])}
+
+@cache_network()
+@coerce_props()
+@annotate()
+def parse(alts=None):
+ global files
+ name = __name__.split(".")[-1]
+ for fnames, alt, fmt in files:
+ if alts is not None and alt not in alts:
+ continue
+ users = {}
+ artists = {}
+ anames = []
+ ambids = []
+ src, tgt, plays = [], [], []
+ # "<user>\t<artist MBID>\t<artist name>\t<plays>"
+ with open_upstream_file(name, fnames[0], "r", errors="replace") as f:
+ for line in f:
+ user, mbid, aname, n = line.rstrip("\n").split("\t")
+ if not mbid and not aname:
+ continue
+ key = mbid if mbid else "name:" + aname
+ a = artists.get(key)
+ if a is None:
+ a = artists[key] = len(artists)
+ anames.append(aname)
+ ambids.append(mbid)
+ src.append(users.setdefault(user, len(users)))
+ tgt.append(a)
+ plays.append(int(float(n)))
+ nu = len(users)
+ g = Graph(directed=False)
+ g.add_vertex(nu + len(artists))
+ g.vp.name = g.new_vp("string", vals=list(users.keys()) + anames)
+ g.vp.is_user = g.new_vp("bool")
+ g.vp.is_user.a[:nu] = True
+ g.vp.mbid = g.new_vp("string")
+ for i, m in enumerate(ambids):
+ if m:
+ g.vp.mbid[nu + i] = m
+ g.ep.weight = g.new_ep("int64_t")
+ g.add_edge_list(numpy.column_stack([numpy.array(src, dtype="int64"),
+ numpy.array(tgt, dtype="int64") + nu,
+ numpy.array(plays, dtype="int64")]),
+ eprops=[g.ep.weight])
+ del src, tgt, plays
+
+ # "<user>\t<gender>\t<age>\t<country>\t<signup date, e.g. Feb 1, 2008>"
+ g.vp.gender = g.new_vp("string")
+ g.vp.age = g.new_vp("int32_t", val=-1)
+ g.vp.country = g.new_vp("string")
+ g.vp.signup = g.new_vp("int64_t", val=-1)
+ with open_upstream_file(name, fnames[1], "r", errors="replace") as f:
+ for line in f:
+ user, gender, age, country, signup = line.rstrip("\n").split("\t")
+ v = users.get(user)
+ if v is None:
+ continue
+ g.vp.gender[v] = gender
+ if age:
+ g.vp.age[v] = int(age)
+ g.vp.country[v] = country
+ if signup:
+ m, d, y = signup.replace(",", "").split()
+ g.vp.signup[v] = calendar.timegm((int(y), _MONTHS[m], int(d),
+ 0, 0, 0))
+ yield alt, g