logo Netzschleuder network catalog, repository, and centrifuge

History of coop_purchases

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 by Tiago de Paula Peixoto 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/coop_purchases/__init__.py b/entries/coop_purchases/__init__.py
index 5a46679..b181952 100644
--- a/entries/coop_purchases/__init__.py
+++ b/entries/coop_purchases/__init__.py
@@ -35,7 +35,7 @@ The customer with identifier 44,617 (in the range from 1 to 60,366) has no purch
 tags = ['Economic', 'Commerce', 'Weighted', 'Multigraph', 'Metadata']
 url = 'https://www.michelecoscia.com/?page_id=379'
 citation = [('D. Pennacchioli, M. Coscia, S. Rinzivillo, D. Pedreschi, F. Giannotti, "Explaining the product range effect in purchase data." 2013 IEEE International Conference on Big Data, 648-656 (2013)', 'https://doi.org/10.1109/BigData.2013.6691634')]
-icon_hash = '575f4ad3bd3e93b53c695699'
+date_added = '2026-10-25'
 upstream_license = None
 upstream_prefix = 'https://michelecoscia.com/wp-content/uploads/2013/02'
 files = [(('supermarket_data.zip:supermarket_purchases',
[entries] Prefix the properties in the descriptions with (Node), (Edge) or (Graph) by Tiago de Paula Peixoto 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/coop_purchases/__init__.py b/entries/coop_purchases/__init__.py
index 938be7e..5a46679 100644
--- a/entries/coop_purchases/__init__.py
+++ b/entries/coop_purchases/__init__.py
@@ -24,12 +24,12 @@ description = """A bipartite network of the customers of the Italian retail comp
 
 The network has the following properties:
 
-- `is_customer`: whether the node is a customer (otherwise it is a product).
-- `id`: the identifier of the customer or of the product in the source data.
-- `price` (products): the unit price of the product in euros, averaged over the time span of the data set.
-- `shop_distance` (customers): the distances, in meters, from the customer's home to each of the five shops (shop identifiers 1 to 5, in this order), measured as straight lines, not along the road network.
-- `shop` (edges): the identifier of the shop (1 to 5) where the purchases were made.
-- `quantity` (edges): the number of items bought.
+- (Node) `is_customer`: whether the node is a customer (otherwise it is a product).
+- (Node) `id`: the identifier of the customer or of the product in the source data.
+- (Node) `price` (products): the unit price of the product in euros, averaged over the time span of the data set.
+- (Node) `shop_distance` (customers): the distances, in meters, from the customer's home to each of the five shops (shop identifiers 1 to 5, in this order), measured as straight lines, not along the road network.
+- (Edge) `shop` (edges): the identifier of the shop (1 to 5) where the purchases were made.
+- (Edge) `quantity` (edges): the number of items bought.
 
 The customer with identifier 44,617 (in the range from 1 to 60,366) has no purchases in the data, and is included as an isolated node."""
 tags = ['Economic', 'Commerce', 'Weighted', 'Multigraph', 'Metadata']
[entries] Remove unneeded code from the entries by Tiago de Paula Peixoto 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/coop_purchases/__init__.py b/entries/coop_purchases/__init__.py
index 7e76f7b..938be7e 100644
--- a/entries/coop_purchases/__init__.py
+++ b/entries/coop_purchases/__init__.py
@@ -50,7 +50,6 @@ def fetch_upstream(force=False):
 @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] Use American spelling in the descriptions by Tiago de Paula Peixoto 802d564
British spellings in the titles and descriptions of 69 entries (e.g.
labelled, organisation, millimetres, centres, anonymised, neighbours,
analysed, modelled, colour, licence) are replaced by the American ones.
Proper names keep their spelling (Otago Harbour, the Centre for Water
Systems, the Centre jeunesse de Montréal, the Dutch Ministry of Defence),
as do quoted upstream terms, citations, and property names.
diff --git a/entries/coop_purchases/__init__.py b/entries/coop_purchases/__init__.py
index a128d8a..7e76f7b 100644
--- a/entries/coop_purchases/__init__.py
+++ b/entries/coop_purchases/__init__.py
@@ -27,7 +27,7 @@ The network has the following properties:
 - `is_customer`: whether the node is a customer (otherwise it is a product).
 - `id`: the identifier of the customer or of the product in the source data.
 - `price` (products): the unit price of the product in euros, averaged over the time span of the data set.
-- `shop_distance` (customers): the distances, in metres, from the customer's home to each of the five shops (shop identifiers 1 to 5, in this order), measured as straight lines, not along the road network.
+- `shop_distance` (customers): the distances, in meters, from the customer's home to each of the five shops (shop identifiers 1 to 5, in this order), measured as straight lines, not along the road network.
 - `shop` (edges): the identifier of the shop (1 to 5) where the purchases were made.
 - `quantity` (edges): the number of items bought.
 
[entries] New entry: coop_purchases by Tiago de Paula Peixoto b776f44
diff --git a/entries/coop_purchases/__init__.py b/entries/coop_purchases/__init__.py
new file mode 100644
index 0000000..a128d8a
--- /dev/null
+++ b/entries/coop_purchases/__init__.py
@@ -0,0 +1,87 @@
+#! /usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2020-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/>.
+
+from .. import *
+import pandas
+
+title = "Coop supermarket purchases (2007-2011)"
+description = """A bipartite network of the customers of the Italian retail company Coop and the products they bought, released by D. Pennacchioli, M. Coscia, S. Rinzivillo, D. Pedreschi and F. Giannotti as the companion data set of their study of the "product range effect". The data cover the purchases recorded between January 2007 and December 2011 by 60,365 anonymized customers (holders of a loyalty card) in five shops of the company, and 4,567 products. Nodes are customers and products, and an edge connects a customer to a product they bought in a given shop, with `quantity` equal to the total number of items of the product bought by the customer in that shop over the whole period. A customer and a product are thus connected by up to five parallel edges, one for each shop.
+
+The network has the following properties:
+
+- `is_customer`: whether the node is a customer (otherwise it is a product).
+- `id`: the identifier of the customer or of the product in the source data.
+- `price` (products): the unit price of the product in euros, averaged over the time span of the data set.
+- `shop_distance` (customers): the distances, in metres, from the customer's home to each of the five shops (shop identifiers 1 to 5, in this order), measured as straight lines, not along the road network.
+- `shop` (edges): the identifier of the shop (1 to 5) where the purchases were made.
+- `quantity` (edges): the number of items bought.
+
+The customer with identifier 44,617 (in the range from 1 to 60,366) has no purchases in the data, and is included as an isolated node."""
+tags = ['Economic', 'Commerce', 'Weighted', 'Multigraph', 'Metadata']
+url = 'https://www.michelecoscia.com/?page_id=379'
+citation = [('D. Pennacchioli, M. Coscia, S. Rinzivillo, D. Pedreschi, F. Giannotti, "Explaining the product range effect in purchase data." 2013 IEEE International Conference on Big Data, 648-656 (2013)', 'https://doi.org/10.1109/BigData.2013.6691634')]
+icon_hash = '575f4ad3bd3e93b53c695699'
+upstream_license = None
+upstream_prefix = 'https://michelecoscia.com/wp-content/uploads/2013/02'
+files = [(('supermarket_data.zip:supermarket_purchases',
+           'supermarket_data.zip:supermarket_prices',
+           'supermarket_data.zip:supermarket_distances'), None, None)]
+
+def fetch_upstream(force=False):
+    return fetch_upstream_files(__name__.split(".")[-1], upstream_prefix, files,
+                                force)
+
+@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
+        with open_upstream_file(name, fnames[0], "rb") as f:
+            p = pandas.read_csv(f, sep=" ")
+        with open_upstream_file(name, fnames[1], "rb") as f:
+            prices = pandas.read_csv(f, sep=" ")
+        with open_upstream_file(name, fnames[2], "rb") as f:
+            dists = pandas.read_csv(f, sep=" ")
+        NC = int(max(p.customer_id.max(), dists.customer_id.max()))
+        NP = int(max(p.product_id.max(), prices.product_id.max()))
+        # Customers are nodes 0..NC-1, products NC..NC+NP-1 (ids start at 1)
+        g = Graph(directed=False)
+        g.add_vertex(NC + NP)
+        g.vp.is_customer = g.new_vp("bool")
+        g.vp.is_customer.a[:NC] = 1
+        g.vp.id = g.new_vp("int")
+        g.vp.id.a[:NC] = numpy.arange(1, NC + 1)
+        g.vp.id.a[NC:] = numpy.arange(1, NP + 1)
+        g.vp.price = g.new_vp("double", val=numpy.nan)
+        g.vp.price.a[NC + prices.product_id.values - 1] = prices.price.values
+        D = numpy.full((NC, 5), numpy.nan)
+        D[dists.customer_id.values - 1, dists.shop_id.values - 1] = dists.distance.values
+        g.vp.shop_distance = g.new_vp("vector<double>")
+        for v in range(NC):
+            g.vp.shop_distance[v] = D[v]
+        g.ep.shop = g.new_ep("int")
+        g.ep.quantity = g.new_ep("int")
+        E = numpy.column_stack((p.customer_id.values - 1,
+                                NC + p.product_id.values - 1,
+                                p.shop_id.values, p.quantity.values))
+        g.add_edge_list(E, eprops=[g.ep.shop, g.ep.quantity])
+        yield alt, g