NodeNova commited on
Commit
3e3d78b
·
verified ·
1 Parent(s): d2e485c

Quick-start: price share of each lot's scored weight (GitHub e7f3154)

Browse files
Files changed (2) hide show
  1. CHANGELOG.md +4 -0
  2. README.md +26 -12
CHANGELOG.md CHANGED
@@ -13,6 +13,10 @@ month it was cut. Load a pinned snapshot with `revision="v2026.10"`.
13
  `unnamed_pct` column, so the four sum to 100 per lot, and drops lots with nothing to
14
  classify. The data is unchanged; only the example was wrong.
15
  - The card asks users to say what they use the dataset for, in a discussion or an issue.
 
 
 
 
16
 
17
  ## v2026.10
18
 
 
13
  `unnamed_pct` column, so the four sum to 100 per lot, and drops lots with nothing to
14
  classify. The data is unchanged; only the example was wrong.
15
  - The card asks users to say what they use the dataset for, in a discussion or an issue.
16
+ - **The card's quick-start query now reports the same metric as query 1**: price share of
17
+ each lot's scored weight, averaged per authority. It used to average the weight of every
18
+ price criterion, including the 0% `Price` line a portal template carries beside its
19
+ placeholder slots, so authorities using that template read close to 0% price.
20
 
21
  ## v2026.10
22
 
README.md CHANGED
@@ -94,18 +94,32 @@ links these three things:
94
  import duckdb
95
 
96
  con = duckdb.connect()
97
- # Mean weight of price criteria, per UK authority (UK-native feeds only, see caveats)
98
- con.sql("""
99
- SELECT b.canonical_name,
100
- round(avg(c.weight_pct) FILTER (WHERE r.role = 'price'), 1) AS mean_price_weight_pct,
101
- count(DISTINCT c.notice_id) AS notices
102
- FROM 'hf://datasets/NodeNovaOrg/bidlens-open-data/data/criteria/*.parquet' c
103
- JOIN 'hf://datasets/NodeNovaOrg/bidlens-open-data/data/buyers/*.parquet' b
104
- ON b.buyer_name = c.buyer_name AND b.buyer_id IS NOT NULL
105
- LEFT JOIN 'hf://datasets/NodeNovaOrg/bidlens-open-data/data/criterion_roles/*.parquet' r
106
- ON r.name = c.name
107
- WHERE c.source IN ('fts_bulk_xml', 'fts_api') AND c.weight_pct IS NOT NULL
108
- GROUP BY b.buyer_id, b.canonical_name HAVING notices >= 10 ORDER BY notices DESC LIMIT 20
 
 
 
 
 
 
 
 
 
 
 
 
 
 
109
  """).show()
110
  ```
111
 
 
94
  import duckdb
95
 
96
  con = duckdb.connect()
97
+ HF = "hf://datasets/NodeNovaOrg/bidlens-open-data/data"
98
+ # Price share of each lot's scored weight, averaged per UK authority (UK-native feeds only).
99
+ # Lots that were not competed, and lots made only of portal placeholder slots, have no split.
100
+ con.sql(f"""
101
+ WITH c AS (
102
+ SELECT c.source, c.notice_id, c.lot_id, c.buyer_name, c.weight_pct,
103
+ CASE WHEN r.role IS NOT NULL AND r.role <> 'unknown' THEN r.role
104
+ WHEN c.criterion_type IN ('price', 'quality') THEN c.criterion_type
105
+ ELSE 'unknown' END AS role
106
+ FROM '{HF}/criteria/*.parquet' c
107
+ LEFT JOIN '{HF}/criterion_roles/*.parquet' r ON r.name = c.name
108
+ WHERE c.source IN ('fts_bulk_xml', 'fts_api') AND c.weight_pct IS NOT NULL
109
+ ), lots AS (
110
+ SELECT source, notice_id, lot_id, min(buyer_name) AS buyer_name,
111
+ sum(CASE WHEN role = 'price' THEN weight_pct ELSE 0 END) AS price,
112
+ sum(CASE WHEN role IN ('quality', 'social_value') THEN weight_pct ELSE 0 END) AS other,
113
+ sum(CASE WHEN role IN ('unknown', 'template_slot') THEN weight_pct ELSE 0 END) AS unnamed,
114
+ bool_or(role IN ('not_competed', 'undisclosed', 'unsplit') AND weight_pct > 0) AS no_contest
115
+ FROM c GROUP BY source, notice_id, lot_id
116
+ )
117
+ SELECT b.canonical_name, count(*) AS lots,
118
+ round(avg(100 * price / (price + other + unnamed)), 1) AS price_share_pct
119
+ FROM lots JOIN '{HF}/buyers/*.parquet' b
120
+ ON b.buyer_name = lots.buyer_name AND b.buyer_id IS NOT NULL
121
+ WHERE NOT no_contest AND price + other > 0
122
+ GROUP BY b.buyer_id, b.canonical_name HAVING lots >= 10 ORDER BY lots DESC LIMIT 20
123
  """).show()
124
  ```
125