remove bloat

This commit is contained in:
2026-11-28 11:23:34 +01:00
parent ce61ff2ca0
commit df6390674a
19 changed files with 100 additions and 10411 deletions
-197
View File
@@ -1,197 +0,0 @@
"""
Download classification, price and genres for every game in data/.
Fast version: bulk price lookups + parallel workers behind a shared rate limiter.
- Game ids come from the file names in data/ (e.g. data/730.csv -> app id 730).
- A row is complete when it has price AND genres. Incomplete or missing rows are (re)fetched,
so the script can be stopped and re-run, and old files without a genres column are upgraded.
- Writes game_tags.csv: sheet, group, name, categories, price, currency, genres
group = sp / mp / both / unknown (from Steam store "categories")
price = base price before discount, 0 if free, "NA" if no price listed
genres = Steam store genres joined by ";" ("none" if the store lists none)
Install: pip install requests
"""
import csv
import glob
import os
import threading
import time
from concurrent.futures import ThreadPoolExecutor, as_completed
import requests
DATA_GLOB = "data/*.csv"
OUT = "game_tags.csv"
API = "https://store.steampowered.com/api/appdetails"
CC = "us"
MIN_INTERVAL = 1.3 # global seconds between requests, shared by all workers
WORKERS = 4
BULK_SIZE = 100 # max ids per price_overview request
SAVE_EVERY = 25
FIELDS = ["sheet", "group", "name", "categories", "price", "currency", "genres"]
MP_CATS = {"multi-player", "co-op", "online co-op", "pvp", "online pvp", "mmo",
"cross-platform multiplayer"}
SP_CATS = {"single-player"}
session = requests.Session()
_lock = threading.Lock()
_next_slot = 0.0 # earliest time the next request may start
def wait_slot(extra_pause=0.0):
"""Reserve the next global request slot (thread safe) and sleep until it."""
global _next_slot
with _lock:
now = time.monotonic()
if extra_pause:
_next_slot = max(_next_slot, now + extra_pause)
start = max(now, _next_slot)
_next_slot = start + MIN_INTERVAL
time.sleep(max(0, start - now))
def get_json(params):
for attempt in range(5):
wait_slot()
try:
r = session.get(API, params={**params, "l": "english", "cc": CC}, timeout=20)
if r.status_code == 429:
wait_slot(extra_pause=60 * (attempt + 1)) # pauses every worker
continue
r.raise_for_status()
return r.json()
except (requests.RequestException, ValueError):
time.sleep(3 * (attempt + 1))
return None
def ids_from_files():
ids = []
for path in sorted(glob.glob(DATA_GLOB)):
stem = os.path.splitext(os.path.basename(path))[0]
if stem.isdigit():
ids.append(stem)
else:
print(f"skipping {path}: file name is not a numeric app id")
return ids
def load_rows():
"""Existing rows keyed by sheet; columns missing in an old file load as blanks."""
if not os.path.exists(OUT):
return {}
with open(OUT, newline="", encoding="utf-8") as f:
return {row["sheet"]: {k: row.get(k) or "" for k in FIELDS} for row in csv.DictReader(f)}
def save_rows(rows):
tmp = OUT + ".tmp"
with open(tmp, "w", newline="", encoding="utf-8") as f:
writer = csv.DictWriter(f, fieldnames=FIELDS)
writer.writeheader()
writer.writerows(rows.values())
os.replace(tmp, OUT)
def classify(categories):
cats = {c.lower() for c in categories}
mp, sp = bool(cats & MP_CATS), bool(cats & SP_CATS)
if mp and sp:
return "both"
if mp:
return "mp"
if sp:
return "sp"
return "unknown"
def get_price(data):
if data.get("is_free"):
return 0, ""
po = data.get("price_overview")
if po:
return round(po["initial"] / 100, 2), po.get("currency", "")
return "NA", ""
def needs_fetch(rows, appid):
r = rows.get(appid)
return r is None or r["price"] == "" or r["genres"] == ""
def bulk_prices(ids):
"""{appid: (price, currency)} for ids that have a price_overview. 100 ids per request."""
out = {}
for i in range(0, len(ids), BULK_SIZE):
chunk = ids[i:i + BULK_SIZE]
js = get_json({"appids": ",".join(chunk), "filters": "price_overview"})
if js is None:
print(f"bulk price batch {i // BULK_SIZE + 1} failed, those ids fall back to single requests")
continue
for appid, entry in js.items():
data = entry.get("data") if entry.get("success") else None
if isinstance(data, dict) and data.get("price_overview"):
po = data["price_overview"]
out[appid] = (round(po["initial"] / 100, 2), po.get("currency", ""))
print(f"bulk prices: {min(i + BULK_SIZE, len(ids))}/{len(ids)}")
return out
def fetch_full(appid):
"""(appid, data dict), data = {} if Steam has no store entry, None on a temporary failure."""
js = get_json({"appids": appid})
if js is None:
return appid, None
try:
entry = js[appid]
return appid, (entry["data"] if entry.get("success") else {})
except (KeyError, TypeError):
return appid, None
def main():
ids = ids_from_files()
rows = load_rows()
need = [i for i in ids if needs_fetch(rows, i)]
print(f"{len(ids)} games in data/, {len(ids) - len(need)} complete, {len(need)} to fetch")
# Step 1: rows that already have genres but miss only the price -> bulk lookup.
# (Genres need the full request, so rows missing genres skip this step.)
price_only = [i for i in need if i in rows and rows[i]["genres"] != ""]
prices = bulk_prices(price_only) if price_only else {}
for appid, (price, cur) in prices.items():
rows[appid]["price"], rows[appid]["currency"] = price, cur
if prices:
save_rows(rows)
# Step 2: everything else (new ids, missing genres, free/unlisted games) -> full request
todo = [i for i in need if i not in prices]
print(f"{len(todo)} need a full request "
f"(about {len(todo) * MIN_INTERVAL / 60:.0f} min at the shared rate limit)")
try:
with ThreadPoolExecutor(WORKERS) as pool:
futures = [pool.submit(fetch_full, i) for i in todo]
for n, fut in enumerate(as_completed(futures), 1):
appid, data = fut.result()
if data is None:
print(f"[{n}/{len(todo)}] {appid}: request failed, will retry on next run")
continue
cats = [c["description"] for c in data.get("categories", [])]
genres = [g["description"] for g in data.get("genres", [])]
price, currency = get_price(data)
rows[appid] = {"sheet": appid, "group": classify(cats), "name": data.get("name", ""),
"categories": ";".join(cats), "price": price, "currency": currency,
"genres": ";".join(genres) or "none"}
print(f"[{n}/{len(todo)}] {appid} {data.get('name', '?')}: {rows[appid]['group']}, "
f"{price} {currency}, {rows[appid]['genres']}")
if n % SAVE_EVERY == 0:
save_rows(rows)
finally:
save_rows(rows)
if __name__ == "__main__":
main()
-69
View File
@@ -1,69 +0,0 @@
spec,group,cutoffs,est,se,p_cluster,p_boot,pct,games_below,games_above,obs,kind
rd,sp,"0.70,0.80,0.95",0.06977589677610212,0.0651955469069849,0.2853703718535656,0.33433433433433435,7.226785564301852,207,226,289269,real
rd,mp,"0.70,0.80,0.95",-0.11586573610411528,0.1100246139251769,0.2970776414460521,0.3923923923923924,-10.940521000329284,46,47,47827,real
rd,both,"0.70,0.80,0.95",0.14116443507937487,0.06981132409895935,0.04463982467804706,0.07307307307307308,15.161399815560817,149,150,168831,real
rd,all,"0.70,0.80,0.95",0.08280772179868487,0.05073494169743983,0.10323455601533937,0.11811811811811812,8.633291032756741,402,423,505927,real
rd,sp,0.70,-0.04144809330500921,0.07814345637154571,0.5984353652877861,0.6156156156156156,-4.060086671277629,30,40,16009,real
rd,mp,0.70,-0.21421668100908847,0.1794679457330567,0.24429191190863797,0.6206206206206206,-19.282653308867037,19,25,11353,real
rd,both,0.70,-0.02594672739611093,0.09159418380142965,0.7782619834134452,0.8188188188188188,-2.5613003641375087,38,42,30736,real
rd,all,0.70,-0.12772535676243213,0.08815992160598593,0.15009363008515697,0.24924924924924924,-11.9904941888495,87,107,58098,real
rd,sp,0.80,0.021962470055520728,0.07466094038692488,0.7694149126854466,0.7847847847847848,2.220542043786722,56,68,57731,real
rd,mp,0.80,0.173108501608406,0.09965821859207331,0.09421843058241453,0.16816816816816818,18.899510596688817,25,22,28263,real
rd,both,0.80,0.25357015941378586,0.12132571573719864,0.03940790285186102,0.07607607607607608,28.861778498224446,73,82,56631,real
rd,all,0.80,0.14720273916073942,0.0722781409535493,0.043026738274295484,0.07407407407407407,15.85888305477765,154,172,142625,real
rd,sp,0.95,0.06634437118140492,0.08548644833056121,0.4386465235355521,0.5015015015015015,6.859464701117379,131,135,215529,real
rd,both,0.95,0.152345350365342,0.09334242817422841,0.10749156927355275,0.15015015015015015,16.45623490259498,53,44,81463,real
rd,all,0.95,0.08441449001419256,0.07150737847476503,0.23883634352149308,0.2822822822822823,8.807979856576132,192,185,305203,real
rd,sp,"0.60,0.75,0.85,0.90",0.059757836006853124,0.050921675678383196,0.24170680660652044,0.3106212424849699,6.157943909951835,212,233,293843,placebo
rd,mp,"0.60,0.75,0.85,0.90",-0.004035927230259323,0.11679628363073945,0.9725666745862851,0.9719438877755511,-0.40277938215829145,45,51,55700,placebo
rd,both,"0.60,0.75,0.85,0.90",-0.01706328292428104,0.060580027128471034,0.7785220409935467,0.7835671342685371,-1.69185296038723,165,162,185933,placebo
rd,all,"0.60,0.75,0.85,0.90",0.00920248589212096,0.039752534204052746,0.8170284302334097,0.8236472945891784,0.9244958951353688,422,446,535477,placebo
rd,sp,0.60,-0.03955998083986333,0.0952800517143765,0.6838757908184414,0.749498997995992,-3.878770205943105,12,16,8793,placebo
rd,mp,0.60,-0.061079764816542204,0.06462695147392157,0.3632431987156406,0.48296593186372744,-5.925180182423007,10,12,7859,placebo
rd,both,0.60,0.13072333130387445,0.12059373620368065,0.28795107404639264,0.4308617234468938,13.965243153802653,23,26,9388,placebo
rd,all,0.60,-0.013266212570350855,0.06489827439758673,0.8387699480402295,0.843687374749499,-1.3178604210654088,45,54,26041,placebo
rd,sp,0.75,-0.08779850735410857,0.1028111084949876,0.3963523094029564,0.48096192384769537,-8.40545856037519,51,56,42857,placebo
rd,mp,0.75,-0.10360811712502269,0.2527932792267738,0.6852710878577692,0.9278557114228457,-9.842145860762875,20,26,22782,placebo
rd,both,0.75,0.0850816730026131,0.1113306115168643,0.44754149550654465,0.6633266533066132,8.88059891214632,52,54,44909,placebo
rd,all,0.75,-0.06875928727141746,0.0934991240811961,0.4631999062402248,0.4969939879759519,-6.644862926811235,123,136,110549,placebo
rd,sp,0.85,0.020386944148207763,0.0733113132099523,0.7814320352858439,0.8316633266533067,2.059617735034247,94,101,107413,placebo
rd,mp,0.85,0.26086155047780357,0.08735544783098131,0.009228225713199478,0.2865731462925852,29.80479388755237,13,12,8237,placebo
rd,both,0.85,-0.0058137560717960125,0.0701255961428603,0.9341034412721667,0.9378757515030061,-0.5796888895012176,79,82,70560,placebo
rd,all,0.85,0.0166348289255315,0.052706214729123395,0.7525815653684684,0.8056112224448898,1.6773958084862706,186,195,186211,placebo
rd,sp,0.90,0.08080255391775878,0.07280808793132691,0.2688843616353671,0.3466933867735471,8.415681291722121,119,117,134779,placebo
rd,mp,0.90,-0.3152851916559152,0.14491760344234197,0.044917275161265424,0.20240480961923848,-27.041922575285902,15,12,16821,placebo
rd,both,0.90,-0.03577273566825194,0.08308368784453353,0.668004981695945,0.685370741482966,-3.5140453271923833,66,49,61075,placebo
rd,all,0.90,0.002673826469143803,0.06712118278305798,0.968256873224667,0.9599198396793587,0.2677404331287603,200,178,212675,placebo
crossers,sp,"0.70,0.80,0.95",0.013970748796574159,0.029258879530683395,0.6338168501318846,0.6416416416416416,1.4068795772019804,131,131,167227,real
crossers,mp,"0.70,0.80,0.95",-0.1162537985918383,0.08923833193143936,0.200937764352634,0.35435435435435436,-10.97507493832801,37,37,35263,real
crossers,both,"0.70,0.80,0.95",0.0863017498527914,0.04184253321772688,0.04144916188068137,0.08008008008008008,9.013522682431008,114,114,115786,real
crossers,all,"0.70,0.80,0.95",0.023771913514224172,0.028043377747406846,0.39733559645150707,0.4124124124124124,2.4056717753129675,282,282,318276,real
crossers,sp,0.70,-0.07662099629761042,0.041440653011362724,0.0773630989299181,0.14514514514514515,-7.375916420340944,24,24,13239,real
crossers,mp,0.70,-0.39344899816323603,0.09675512147663641,0.000724343971491237,0.018018018018018018,-32.52742710491684,19,19,10361,real
crossers,both,0.70,0.052915546355270834,0.04533144875302382,0.25145355843569805,0.3013013013013013,5.4340598452925715,34,34,22521,real
crossers,all,0.70,-0.10927843494380063,0.07433238035624934,0.14565387549814934,0.2682682682682683,-10.351922882842167,77,77,46121,real
crossers,sp,0.80,0.029889240364722843,0.05636795022515568,0.5986029523633141,0.6386386386386387,3.0340407505585087,45,45,47421,real
crossers,mp,0.80,0.04853709982557234,0.07996328619191811,0.5510414175140377,0.6826826826826827,4.973431605793155,20,20,21176,real
crossers,both,0.80,0.06249498415450746,0.03773457142728681,0.10273985204748004,0.19019019019019018,6.448911959151649,63,63,46905,real
crossers,all,0.80,0.036672584747822805,0.03629741104243463,0.3142553423868937,0.33933933933933935,3.735331993072055,128,128,115502,real
crossers,sp,0.95,0.012524767187365298,0.03272035270230878,0.7030411716160447,0.6946946946946947,1.260353057143293,71,71,106567,real
crossers,both,0.95,0.06598024716169724,0.08033471652414781,0.4179452483751884,0.4724724724724725,6.8205616864774665,31,31,46359,real
crossers,all,0.95,0.02413213421767054,0.03695329868804763,0.5151689154348846,0.5435435435435435,2.442567063261092,105,105,156652,real
crossers,sp,"0.60,0.75,0.85,0.90",0.020108201122091482,0.029524563532404145,0.4966995955818876,0.5110220440881763,2.031173292871613,182,182,225425,placebo
crossers,mp,"0.60,0.75,0.85,0.90",-0.16124296983839087,0.09429044042711372,0.09562818085746416,0.156312625250501,-14.89147420640904,38,38,41414,placebo
crossers,both,"0.60,0.75,0.85,0.90",-0.04503219185056594,0.02633582782742629,0.08959495624179237,0.12024048096192384,-4.403329299962467,135,135,140769,placebo
crossers,all,"0.60,0.75,0.85,0.90",-0.025805856670577124,0.02527422079586863,0.3079352505932358,0.3246492985971944,-2.547573136965209,355,355,407609,placebo
crossers,sp,0.60,0.02892719858112294,0.09084439913275634,0.7567127156466578,0.0,2.934965363195907,11,11,7822,placebo
crossers,both,0.60,0.01918095540586597,0.07019871476515374,0.7874719090372295,0.8416833667334669,1.9366091733771018,21,21,8836,placebo
crossers,all,0.60,-0.024549248745847917,0.036992448354180044,0.5107350278383238,0.5350701402805611,-2.425036671062375,41,41,21398,placebo
crossers,sp,0.75,-0.04918971648963493,0.09271139089662724,0.5985124080725361,0.7454909819639278,-4.7999497628385175,43,43,35532,placebo
crossers,mp,0.75,0.02609423855366563,0.08802009602366145,0.7704718031147131,0.8196392785571143,2.643767391755536,18,18,16909,placebo
crossers,both,0.75,0.03157639207400229,0.03317364133474998,0.3468886703818057,0.36072144288577157,3.2080215332427997,41,41,36432,placebo
crossers,all,0.75,-0.07035279262770973,0.07181503967160327,0.3296052399097822,0.44488977955911824,-6.79350637425623,102,102,88873,placebo
crossers,sp,0.85,0.01790666236865091,0.03917059267989924,0.6488878437951211,0.6432865731462926,1.8067947904186088,76,76,88095,placebo
crossers,both,0.85,0.0009329596911895152,0.0415700948111168,0.982164367864667,0.0,0.09333950334573515,65,65,56643,placebo
crossers,all,0.85,0.02220314136273311,0.03216922539328535,0.4911432292296556,0.5150300601202404,2.245146555945654,150,150,149884,placebo
crossers,sp,0.90,0.02774744286648366,0.0498219533417962,0.5790203804640919,0.593186372745491,2.8135988550649804,87,87,93976,placebo
crossers,mp,0.90,-0.35034616630694954,0.1401138672586952,0.033837450198500596,0.20040080160320642,-29.555580733794862,10,10,14619,placebo
crossers,both,0.90,-0.14570361816748104,0.057430073441788576,0.015526493481147874,0.01603206412825651,-13.55861382131992,38,38,38858,placebo
crossers,all,0.90,-0.05700038261490047,0.04121779730284615,0.1689934606723147,0.19238476953907815,-5.540629204917336,135,135,147453,placebo
1 spec group cutoffs est se p_cluster p_boot pct games_below games_above obs kind
2 rd sp 0.70,0.80,0.95 0.06977589677610212 0.0651955469069849 0.2853703718535656 0.33433433433433435 7.226785564301852 207 226 289269 real
3 rd mp 0.70,0.80,0.95 -0.11586573610411528 0.1100246139251769 0.2970776414460521 0.3923923923923924 -10.940521000329284 46 47 47827 real
4 rd both 0.70,0.80,0.95 0.14116443507937487 0.06981132409895935 0.04463982467804706 0.07307307307307308 15.161399815560817 149 150 168831 real
5 rd all 0.70,0.80,0.95 0.08280772179868487 0.05073494169743983 0.10323455601533937 0.11811811811811812 8.633291032756741 402 423 505927 real
6 rd sp 0.70 -0.04144809330500921 0.07814345637154571 0.5984353652877861 0.6156156156156156 -4.060086671277629 30 40 16009 real
7 rd mp 0.70 -0.21421668100908847 0.1794679457330567 0.24429191190863797 0.6206206206206206 -19.282653308867037 19 25 11353 real
8 rd both 0.70 -0.02594672739611093 0.09159418380142965 0.7782619834134452 0.8188188188188188 -2.5613003641375087 38 42 30736 real
9 rd all 0.70 -0.12772535676243213 0.08815992160598593 0.15009363008515697 0.24924924924924924 -11.9904941888495 87 107 58098 real
10 rd sp 0.80 0.021962470055520728 0.07466094038692488 0.7694149126854466 0.7847847847847848 2.220542043786722 56 68 57731 real
11 rd mp 0.80 0.173108501608406 0.09965821859207331 0.09421843058241453 0.16816816816816818 18.899510596688817 25 22 28263 real
12 rd both 0.80 0.25357015941378586 0.12132571573719864 0.03940790285186102 0.07607607607607608 28.861778498224446 73 82 56631 real
13 rd all 0.80 0.14720273916073942 0.0722781409535493 0.043026738274295484 0.07407407407407407 15.85888305477765 154 172 142625 real
14 rd sp 0.95 0.06634437118140492 0.08548644833056121 0.4386465235355521 0.5015015015015015 6.859464701117379 131 135 215529 real
15 rd both 0.95 0.152345350365342 0.09334242817422841 0.10749156927355275 0.15015015015015015 16.45623490259498 53 44 81463 real
16 rd all 0.95 0.08441449001419256 0.07150737847476503 0.23883634352149308 0.2822822822822823 8.807979856576132 192 185 305203 real
17 rd sp 0.60,0.75,0.85,0.90 0.059757836006853124 0.050921675678383196 0.24170680660652044 0.3106212424849699 6.157943909951835 212 233 293843 placebo
18 rd mp 0.60,0.75,0.85,0.90 -0.004035927230259323 0.11679628363073945 0.9725666745862851 0.9719438877755511 -0.40277938215829145 45 51 55700 placebo
19 rd both 0.60,0.75,0.85,0.90 -0.01706328292428104 0.060580027128471034 0.7785220409935467 0.7835671342685371 -1.69185296038723 165 162 185933 placebo
20 rd all 0.60,0.75,0.85,0.90 0.00920248589212096 0.039752534204052746 0.8170284302334097 0.8236472945891784 0.9244958951353688 422 446 535477 placebo
21 rd sp 0.60 -0.03955998083986333 0.0952800517143765 0.6838757908184414 0.749498997995992 -3.878770205943105 12 16 8793 placebo
22 rd mp 0.60 -0.061079764816542204 0.06462695147392157 0.3632431987156406 0.48296593186372744 -5.925180182423007 10 12 7859 placebo
23 rd both 0.60 0.13072333130387445 0.12059373620368065 0.28795107404639264 0.4308617234468938 13.965243153802653 23 26 9388 placebo
24 rd all 0.60 -0.013266212570350855 0.06489827439758673 0.8387699480402295 0.843687374749499 -1.3178604210654088 45 54 26041 placebo
25 rd sp 0.75 -0.08779850735410857 0.1028111084949876 0.3963523094029564 0.48096192384769537 -8.40545856037519 51 56 42857 placebo
26 rd mp 0.75 -0.10360811712502269 0.2527932792267738 0.6852710878577692 0.9278557114228457 -9.842145860762875 20 26 22782 placebo
27 rd both 0.75 0.0850816730026131 0.1113306115168643 0.44754149550654465 0.6633266533066132 8.88059891214632 52 54 44909 placebo
28 rd all 0.75 -0.06875928727141746 0.0934991240811961 0.4631999062402248 0.4969939879759519 -6.644862926811235 123 136 110549 placebo
29 rd sp 0.85 0.020386944148207763 0.0733113132099523 0.7814320352858439 0.8316633266533067 2.059617735034247 94 101 107413 placebo
30 rd mp 0.85 0.26086155047780357 0.08735544783098131 0.009228225713199478 0.2865731462925852 29.80479388755237 13 12 8237 placebo
31 rd both 0.85 -0.0058137560717960125 0.0701255961428603 0.9341034412721667 0.9378757515030061 -0.5796888895012176 79 82 70560 placebo
32 rd all 0.85 0.0166348289255315 0.052706214729123395 0.7525815653684684 0.8056112224448898 1.6773958084862706 186 195 186211 placebo
33 rd sp 0.90 0.08080255391775878 0.07280808793132691 0.2688843616353671 0.3466933867735471 8.415681291722121 119 117 134779 placebo
34 rd mp 0.90 -0.3152851916559152 0.14491760344234197 0.044917275161265424 0.20240480961923848 -27.041922575285902 15 12 16821 placebo
35 rd both 0.90 -0.03577273566825194 0.08308368784453353 0.668004981695945 0.685370741482966 -3.5140453271923833 66 49 61075 placebo
36 rd all 0.90 0.002673826469143803 0.06712118278305798 0.968256873224667 0.9599198396793587 0.2677404331287603 200 178 212675 placebo
37 crossers sp 0.70,0.80,0.95 0.013970748796574159 0.029258879530683395 0.6338168501318846 0.6416416416416416 1.4068795772019804 131 131 167227 real
38 crossers mp 0.70,0.80,0.95 -0.1162537985918383 0.08923833193143936 0.200937764352634 0.35435435435435436 -10.97507493832801 37 37 35263 real
39 crossers both 0.70,0.80,0.95 0.0863017498527914 0.04184253321772688 0.04144916188068137 0.08008008008008008 9.013522682431008 114 114 115786 real
40 crossers all 0.70,0.80,0.95 0.023771913514224172 0.028043377747406846 0.39733559645150707 0.4124124124124124 2.4056717753129675 282 282 318276 real
41 crossers sp 0.70 -0.07662099629761042 0.041440653011362724 0.0773630989299181 0.14514514514514515 -7.375916420340944 24 24 13239 real
42 crossers mp 0.70 -0.39344899816323603 0.09675512147663641 0.000724343971491237 0.018018018018018018 -32.52742710491684 19 19 10361 real
43 crossers both 0.70 0.052915546355270834 0.04533144875302382 0.25145355843569805 0.3013013013013013 5.4340598452925715 34 34 22521 real
44 crossers all 0.70 -0.10927843494380063 0.07433238035624934 0.14565387549814934 0.2682682682682683 -10.351922882842167 77 77 46121 real
45 crossers sp 0.80 0.029889240364722843 0.05636795022515568 0.5986029523633141 0.6386386386386387 3.0340407505585087 45 45 47421 real
46 crossers mp 0.80 0.04853709982557234 0.07996328619191811 0.5510414175140377 0.6826826826826827 4.973431605793155 20 20 21176 real
47 crossers both 0.80 0.06249498415450746 0.03773457142728681 0.10273985204748004 0.19019019019019018 6.448911959151649 63 63 46905 real
48 crossers all 0.80 0.036672584747822805 0.03629741104243463 0.3142553423868937 0.33933933933933935 3.735331993072055 128 128 115502 real
49 crossers sp 0.95 0.012524767187365298 0.03272035270230878 0.7030411716160447 0.6946946946946947 1.260353057143293 71 71 106567 real
50 crossers both 0.95 0.06598024716169724 0.08033471652414781 0.4179452483751884 0.4724724724724725 6.8205616864774665 31 31 46359 real
51 crossers all 0.95 0.02413213421767054 0.03695329868804763 0.5151689154348846 0.5435435435435435 2.442567063261092 105 105 156652 real
52 crossers sp 0.60,0.75,0.85,0.90 0.020108201122091482 0.029524563532404145 0.4966995955818876 0.5110220440881763 2.031173292871613 182 182 225425 placebo
53 crossers mp 0.60,0.75,0.85,0.90 -0.16124296983839087 0.09429044042711372 0.09562818085746416 0.156312625250501 -14.89147420640904 38 38 41414 placebo
54 crossers both 0.60,0.75,0.85,0.90 -0.04503219185056594 0.02633582782742629 0.08959495624179237 0.12024048096192384 -4.403329299962467 135 135 140769 placebo
55 crossers all 0.60,0.75,0.85,0.90 -0.025805856670577124 0.02527422079586863 0.3079352505932358 0.3246492985971944 -2.547573136965209 355 355 407609 placebo
56 crossers sp 0.60 0.02892719858112294 0.09084439913275634 0.7567127156466578 0.0 2.934965363195907 11 11 7822 placebo
57 crossers both 0.60 0.01918095540586597 0.07019871476515374 0.7874719090372295 0.8416833667334669 1.9366091733771018 21 21 8836 placebo
58 crossers all 0.60 -0.024549248745847917 0.036992448354180044 0.5107350278383238 0.5350701402805611 -2.425036671062375 41 41 21398 placebo
59 crossers sp 0.75 -0.04918971648963493 0.09271139089662724 0.5985124080725361 0.7454909819639278 -4.7999497628385175 43 43 35532 placebo
60 crossers mp 0.75 0.02609423855366563 0.08802009602366145 0.7704718031147131 0.8196392785571143 2.643767391755536 18 18 16909 placebo
61 crossers both 0.75 0.03157639207400229 0.03317364133474998 0.3468886703818057 0.36072144288577157 3.2080215332427997 41 41 36432 placebo
62 crossers all 0.75 -0.07035279262770973 0.07181503967160327 0.3296052399097822 0.44488977955911824 -6.79350637425623 102 102 88873 placebo
63 crossers sp 0.85 0.01790666236865091 0.03917059267989924 0.6488878437951211 0.6432865731462926 1.8067947904186088 76 76 88095 placebo
64 crossers both 0.85 0.0009329596911895152 0.0415700948111168 0.982164367864667 0.0 0.09333950334573515 65 65 56643 placebo
65 crossers all 0.85 0.02220314136273311 0.03216922539328535 0.4911432292296556 0.5150300601202404 2.245146555945654 150 150 149884 placebo
66 crossers sp 0.90 0.02774744286648366 0.0498219533417962 0.5790203804640919 0.593186372745491 2.8135988550649804 87 87 93976 placebo
67 crossers mp 0.90 -0.35034616630694954 0.1401138672586952 0.033837450198500596 0.20040080160320642 -29.555580733794862 10 10 14619 placebo
68 crossers both 0.90 -0.14570361816748104 0.057430073441788576 0.015526493481147874 0.01603206412825651 -13.55861382131992 38 38 38858 placebo
69 crossers all 0.90 -0.05700038261490047 0.04121779730284615 0.1689934606723147 0.19238476953907815 -5.540629204917336 135 135 147453 placebo
-17
View File
@@ -1,17 +0,0 @@
spec,group,effect,est,se,p_cluster,p_boot,pct,obs
rd,sp,placebo jump (D),-0.005170940167028049,0.05488107849219133,0.9249785726456707,0.9079079079079079,-0.5157593870132815,889835
rd,sp,real minus placebo (D_x_real),0.05273364754141571,0.08766960886413708,0.5478278927919431,0.5455455455455456,5.414883259018821,889835
rd,mp,placebo jump (D),0.011928716366942227,0.15571292616971652,0.9391788758028419,0.953953953953954,1.2000147247699156,139642
rd,mp,real minus placebo (D_x_real),-0.28706924098800624,0.2198579604470944,0.19640148952325598,0.25725725725725723,-24.954023553749394,139642
rd,both,placebo jump (D),-0.016032323710668664,0.06199503216936062,0.7961515857825088,0.8108108108108109,-1.5904490077355948,518517
rd,both,real minus placebo (D_x_real),0.1457867561057011,0.10792357613839959,0.17797020343029213,0.2002002002002002,15.694944933788534,518517
rd,all,placebo jump (D),-0.03456285364560534,0.04330316833124592,0.4250351416132778,0.4394394394394394,-3.3972380579369466,1547994
rd,all,real minus placebo (D_x_real),0.09937814992479586,0.06977093646437785,0.1547693700927013,0.14914914914914915,10.448388109626716,1547994
crossers,sp,placebo jump (D),0.011129802176277336,0.030550214329010096,0.7159190721947652,0.7247247247247247,1.1191968844691313,503647
crossers,sp,real minus placebo (D_x_real),-0.012758592171361357,0.0418596760432984,0.7607647699262867,0.7647647647647647,-1.2677546377162674,503647
crossers,mp,placebo jump (D),-0.14983610883291007,0.1298116069336355,0.25357257209453143,0.3483483483483483,-13.915094958008723,98823
crossers,mp,real minus placebo (D_x_real),0.04890221037276008,0.16063707709770966,0.7619949993463968,0.8028028028028028,5.011765510477528,98823
crossers,both,placebo jump (D),-0.04562590856387067,0.03359344514303505,0.17600071781205084,0.2022022022022022,-4.460069795536336,333283
crossers,both,real minus placebo (D_x_real),0.12406217914544339,0.053826777266037414,0.02224482568470365,0.03003003003003003,13.20862609670337,333283
crossers,all,placebo jump (D),-0.026538615920839087,0.02743846699398653,0.33390101155400664,0.3613613613613614,-2.618956147734841,935753
crossers,all,real minus placebo (D_x_real),0.04918382865071978,0.03886123064453395,0.2062256123616677,0.23323323323323322,5.04134290761844,935753
1 spec group effect est se p_cluster p_boot pct obs
2 rd sp placebo jump (D) -0.005170940167028049 0.05488107849219133 0.9249785726456707 0.9079079079079079 -0.5157593870132815 889835
3 rd sp real minus placebo (D_x_real) 0.05273364754141571 0.08766960886413708 0.5478278927919431 0.5455455455455456 5.414883259018821 889835
4 rd mp placebo jump (D) 0.011928716366942227 0.15571292616971652 0.9391788758028419 0.953953953953954 1.2000147247699156 139642
5 rd mp real minus placebo (D_x_real) -0.28706924098800624 0.2198579604470944 0.19640148952325598 0.25725725725725723 -24.954023553749394 139642
6 rd both placebo jump (D) -0.016032323710668664 0.06199503216936062 0.7961515857825088 0.8108108108108109 -1.5904490077355948 518517
7 rd both real minus placebo (D_x_real) 0.1457867561057011 0.10792357613839959 0.17797020343029213 0.2002002002002002 15.694944933788534 518517
8 rd all placebo jump (D) -0.03456285364560534 0.04330316833124592 0.4250351416132778 0.4394394394394394 -3.3972380579369466 1547994
9 rd all real minus placebo (D_x_real) 0.09937814992479586 0.06977093646437785 0.1547693700927013 0.14914914914914915 10.448388109626716 1547994
10 crossers sp placebo jump (D) 0.011129802176277336 0.030550214329010096 0.7159190721947652 0.7247247247247247 1.1191968844691313 503647
11 crossers sp real minus placebo (D_x_real) -0.012758592171361357 0.0418596760432984 0.7607647699262867 0.7647647647647647 -1.2677546377162674 503647
12 crossers mp placebo jump (D) -0.14983610883291007 0.1298116069336355 0.25357257209453143 0.3483483483483483 -13.915094958008723 98823
13 crossers mp real minus placebo (D_x_real) 0.04890221037276008 0.16063707709770966 0.7619949993463968 0.8028028028028028 5.011765510477528 98823
14 crossers both placebo jump (D) -0.04562590856387067 0.03359344514303505 0.17600071781205084 0.2022022022022022 -4.460069795536336 333283
15 crossers both real minus placebo (D_x_real) 0.12406217914544339 0.053826777266037414 0.02224482568470365 0.03003003003003003 13.20862609670337 333283
16 crossers all placebo jump (D) -0.026538615920839087 0.02743846699398653 0.33390101155400664 0.3613613613613614 -2.618956147734841 935753
17 crossers all real minus placebo (D_x_real) 0.04918382865071978 0.03886123064453395 0.2062256123616677 0.23323323323323322 5.04134290761844 935753
-45
View File
@@ -1,45 +0,0 @@
spec,cutoffs,effect,est,se,p_cluster,p_boot,pct,games_sp,games_mp,obs,kind,groups,games
rd,"0.70,0.80,0.95",ell (single-player),0.265208179120153,0.16873546980853776,0.1174883263107167,0.36736736736736736,30.370235113844824,177.0,38.0,108814.0,real,2,
rd,"0.70,0.80,0.95",lambda (MP - SP),0.24079426821949287,0.1438965071571863,0.09571258872786093,0.15715715715715717,27.225926421814183,177.0,38.0,108814.0,real,2,
rd,"0.70,0.80,0.95",ell + lambda (multiplayer),0.5060024473396475,0.17595823428508237,0.004438821752944966,0.03803803803803804,65.86473940188667,177.0,38.0,108814.0,real,2,
rd,"0.60,0.75,0.85,0.90",ell (single-player),-0.11451090769572225,0.10680035469337845,0.2851698141725958,0.44288577154308617,-10.819778914208777,127.0,42.0,68608.0,placebo,2,
rd,"0.60,0.75,0.85,0.90",lambda (MP - SP),0.6515154913544425,0.1641431621054619,0.00010668735717511701,0.004008016032064128,91.84460154157541,127.0,42.0,68608.0,placebo,2,
rd,"0.60,0.75,0.85,0.90",ell + lambda (multiplayer),0.5370045836587134,0.11925211523248967,1.2481834758659716e-05,0.0,71.08743979593099,127.0,42.0,68608.0,placebo,2,
rd,0.75,ell (single-player),0.11135281539831196,0.1314350126338556,0.39985109837616317,0.45490981963927857,11.77892105377072,43.0,26.0,15501.0,placebo,2,
rd,0.75,lambda (MP - SP),0.2812247567306166,0.155502444092685,0.07495151997209204,0.12625250501002003,32.47513172524139,43.0,26.0,15501.0,placebo,2,
rd,0.75,ell + lambda (multiplayer),0.39257757212893246,0.12504981706856744,0.0025048505516682695,0.028056112224448898,48.07927290703691,43.0,26.0,15501.0,placebo,2,
rd,0.85,ell (single-player),-0.08368826147021466,0.13172288198583487,0.5281654321932019,0.625250501002004,-8.028207707663526,36.0,14.0,23709.0,placebo,2,
rd,0.85,lambda (MP - SP),0.4212412808507639,0.22036531051087754,0.06179033795158562,0.21643286573146292,52.385191034106306,36.0,14.0,23709.0,placebo,2,
rd,0.85,ell + lambda (multiplayer),0.33755301938055055,0.14757691449839921,0.026534704862240854,0.04208416833667335,40.15139138216857,36.0,14.0,23709.0,placebo,2,
crossers,"0.70,0.80,0.95",ell (single-player),-0.07929516006425846,0.06778788082328821,0.24522297823335815,0.3333333333333333,-7.623277499141845,65.0,25.0,68971.0,real,2,
crossers,"0.70,0.80,0.95",lambda (MP - SP),0.0597621254417001,0.10670142873337357,0.576826898011604,0.6206206206206206,6.158399268512338,65.0,25.0,68971.0,real,2,
crossers,"0.70,0.80,0.95",ell + lambda (multiplayer),-0.01953303462255829,0.07296467959984361,0.7895455662428343,0.8118118118118118,-1.9343500963733162,65.0,25.0,68971.0,real,2,
crossers,"0.60,0.75,0.85,0.90",ell (single-player),0.1071558905145822,0.07857216346093678,0.17599787040066261,0.27054108216432865,11.310776389683742,65.0,27.0,55071.0,placebo,2,
crossers,"0.60,0.75,0.85,0.90",lambda (MP - SP),0.019512580289508755,0.1057832820909215,0.8540645653548062,0.8496993987975952,1.970419495395337,65.0,27.0,55071.0,placebo,2,
crossers,"0.60,0.75,0.85,0.90",ell + lambda (multiplayer),0.12666847080409016,0.07870720189164024,0.11100077983063006,0.19839679358717435,13.504065628141904,65.0,27.0,55071.0,placebo,2,
crossers,0.75,ell (single-player),0.0013139975431374054,0.08451518928250158,0.9876862890862474,0.9939879759519038,0.13148612161557605,19.0,16.0,11487.0,placebo,2,
crossers,0.75,lambda (MP - SP),0.0799733679439065,0.16400626669556098,0.628945901649909,0.7194388777555111,8.325821789717303,19.0,16.0,11487.0,placebo,2,
crossers,0.75,ell + lambda (multiplayer),0.0812873654870437,0.1323435439036874,0.5431618285215545,0.6533066132264529,8.468255211496768,19.0,16.0,11487.0,placebo,2,
crossers,0.85,ell (single-player),0.17623006304267946,0.1219173518155334,0.1590415988104783,0.35070140280561124,19.271242613834882,20.0,10.0,20386.0,placebo,2,
crossers,0.85,lambda (MP - SP),-0.022914461005779638,0.1350161499242592,0.8664115353890729,0.905811623246493,-2.2653918601394207,20.0,10.0,20386.0,placebo,2,
crossers,0.85,ell + lambda (multiplayer),0.1533156020368989,0.05851685664585496,0.013845652108582351,0.014028056112224449,16.569281592173812,20.0,10.0,20386.0,placebo,2,
crossers,"0.70,0.80,0.95",ell single-player,0.006329104879160874,0.08233233043910523,0.9388185528481667,0.9579579579579579,,,,,real,3,65.0
crossers,"0.70,0.80,0.95",ell multiplayer-only,-0.0059583438610938885,0.08566461791712103,0.9446331363801392,0.953953953953954,,,,,real,3,25.0
crossers,"0.70,0.80,0.95",ell both,0.08719847247799399,0.055314223063373906,0.11685596035126666,0.14514514514514515,,,,,real,3,75.0
crossers,"0.70,0.80,0.95",mp-only minus sp,-0.012287448740288129,0.12504481186773275,0.9218423734196226,0.943943943943944,,,,,real,3,
crossers,"0.70,0.80,0.95",both minus sp,0.08086936759878514,0.09537211806148527,0.39770994272513716,0.4394394394394394,,,,,real,3,
crossers,"0.60,0.75,0.85,0.90",ell single-player,0.07166992971293004,0.08492424818509708,0.3997938592550334,0.4248496993987976,,,,,placebo,3,65.0
crossers,"0.60,0.75,0.85,0.90",ell multiplayer-only,0.08369987916768806,0.07223515341134175,0.24805830610588142,0.3306613226452906,,,,,placebo,3,27.0
crossers,"0.60,0.75,0.85,0.90",ell both,0.08097278504646685,0.04052070166292885,0.04714012831741732,0.04408817635270541,,,,,placebo,3,95.0
crossers,"0.60,0.75,0.85,0.90",mp-only minus sp,0.012029949454759326,0.10754642649982243,0.9110564624887634,0.9118236472945892,,,,,placebo,3,
crossers,"0.60,0.75,0.85,0.90",both minus sp,0.009302855333533111,0.08895211301832538,0.9168196030994746,0.9278557114228457,,,,,placebo,3,
rd,"0.70,0.80,0.95",ell single-player,0.22545741499110764,0.1362364880567935,0.09878418663672184,0.18118118118118118,,,,,real,3,177.0
rd,"0.70,0.80,0.95",ell multiplayer-only,0.43028002694371525,0.13348361370462755,0.0013777404581201136,0.01901901901901902,,,,,real,3,38.0
rd,"0.70,0.80,0.95",ell both,0.07930716957903333,0.12198106250822549,0.5159882355360925,0.6256256256256256,,,,,real,3,160.0
rd,"0.70,0.80,0.95",mp-only minus sp,0.20482261195260873,0.1477325368261786,0.1664378534075701,0.22422422422422422,,,,,real,3,
rd,"0.70,0.80,0.95",both minus sp,-0.14615024541207766,0.11461614865696096,0.20305552021560191,0.22522522522522523,,,,,real,3,
rd,"0.60,0.75,0.85,0.90",ell single-player,-0.22105247468145903,0.11121985594200143,0.04767305942380484,0.09619238476953908,,,,,placebo,3,127.0
rd,"0.60,0.75,0.85,0.90",ell multiplayer-only,0.2921179444375056,0.12033409256097834,0.015724211753443518,0.03006012024048096,,,,,placebo,3,42.0
rd,"0.60,0.75,0.85,0.90",ell both,0.036533405214211175,0.07519781957403315,0.627402972967396,0.6593186372745491,,,,,placebo,3,169.0
rd,"0.60,0.75,0.85,0.90",mp-only minus sp,0.5131704191189583,0.1583899177891829,0.0013148092559693847,0.012024048096192385,,,,,placebo,3,
rd,"0.60,0.75,0.85,0.90",both minus sp,0.2575858798956652,0.12785532757291568,0.04473350853787239,0.1282565130260521,,,,,placebo,3,
1 spec cutoffs effect est se p_cluster p_boot pct games_sp games_mp obs kind groups games
2 rd 0.70,0.80,0.95 ell (single-player) 0.265208179120153 0.16873546980853776 0.1174883263107167 0.36736736736736736 30.370235113844824 177.0 38.0 108814.0 real 2
3 rd 0.70,0.80,0.95 lambda (MP - SP) 0.24079426821949287 0.1438965071571863 0.09571258872786093 0.15715715715715717 27.225926421814183 177.0 38.0 108814.0 real 2
4 rd 0.70,0.80,0.95 ell + lambda (multiplayer) 0.5060024473396475 0.17595823428508237 0.004438821752944966 0.03803803803803804 65.86473940188667 177.0 38.0 108814.0 real 2
5 rd 0.60,0.75,0.85,0.90 ell (single-player) -0.11451090769572225 0.10680035469337845 0.2851698141725958 0.44288577154308617 -10.819778914208777 127.0 42.0 68608.0 placebo 2
6 rd 0.60,0.75,0.85,0.90 lambda (MP - SP) 0.6515154913544425 0.1641431621054619 0.00010668735717511701 0.004008016032064128 91.84460154157541 127.0 42.0 68608.0 placebo 2
7 rd 0.60,0.75,0.85,0.90 ell + lambda (multiplayer) 0.5370045836587134 0.11925211523248967 1.2481834758659716e-05 0.0 71.08743979593099 127.0 42.0 68608.0 placebo 2
8 rd 0.75 ell (single-player) 0.11135281539831196 0.1314350126338556 0.39985109837616317 0.45490981963927857 11.77892105377072 43.0 26.0 15501.0 placebo 2
9 rd 0.75 lambda (MP - SP) 0.2812247567306166 0.155502444092685 0.07495151997209204 0.12625250501002003 32.47513172524139 43.0 26.0 15501.0 placebo 2
10 rd 0.75 ell + lambda (multiplayer) 0.39257757212893246 0.12504981706856744 0.0025048505516682695 0.028056112224448898 48.07927290703691 43.0 26.0 15501.0 placebo 2
11 rd 0.85 ell (single-player) -0.08368826147021466 0.13172288198583487 0.5281654321932019 0.625250501002004 -8.028207707663526 36.0 14.0 23709.0 placebo 2
12 rd 0.85 lambda (MP - SP) 0.4212412808507639 0.22036531051087754 0.06179033795158562 0.21643286573146292 52.385191034106306 36.0 14.0 23709.0 placebo 2
13 rd 0.85 ell + lambda (multiplayer) 0.33755301938055055 0.14757691449839921 0.026534704862240854 0.04208416833667335 40.15139138216857 36.0 14.0 23709.0 placebo 2
14 crossers 0.70,0.80,0.95 ell (single-player) -0.07929516006425846 0.06778788082328821 0.24522297823335815 0.3333333333333333 -7.623277499141845 65.0 25.0 68971.0 real 2
15 crossers 0.70,0.80,0.95 lambda (MP - SP) 0.0597621254417001 0.10670142873337357 0.576826898011604 0.6206206206206206 6.158399268512338 65.0 25.0 68971.0 real 2
16 crossers 0.70,0.80,0.95 ell + lambda (multiplayer) -0.01953303462255829 0.07296467959984361 0.7895455662428343 0.8118118118118118 -1.9343500963733162 65.0 25.0 68971.0 real 2
17 crossers 0.60,0.75,0.85,0.90 ell (single-player) 0.1071558905145822 0.07857216346093678 0.17599787040066261 0.27054108216432865 11.310776389683742 65.0 27.0 55071.0 placebo 2
18 crossers 0.60,0.75,0.85,0.90 lambda (MP - SP) 0.019512580289508755 0.1057832820909215 0.8540645653548062 0.8496993987975952 1.970419495395337 65.0 27.0 55071.0 placebo 2
19 crossers 0.60,0.75,0.85,0.90 ell + lambda (multiplayer) 0.12666847080409016 0.07870720189164024 0.11100077983063006 0.19839679358717435 13.504065628141904 65.0 27.0 55071.0 placebo 2
20 crossers 0.75 ell (single-player) 0.0013139975431374054 0.08451518928250158 0.9876862890862474 0.9939879759519038 0.13148612161557605 19.0 16.0 11487.0 placebo 2
21 crossers 0.75 lambda (MP - SP) 0.0799733679439065 0.16400626669556098 0.628945901649909 0.7194388777555111 8.325821789717303 19.0 16.0 11487.0 placebo 2
22 crossers 0.75 ell + lambda (multiplayer) 0.0812873654870437 0.1323435439036874 0.5431618285215545 0.6533066132264529 8.468255211496768 19.0 16.0 11487.0 placebo 2
23 crossers 0.85 ell (single-player) 0.17623006304267946 0.1219173518155334 0.1590415988104783 0.35070140280561124 19.271242613834882 20.0 10.0 20386.0 placebo 2
24 crossers 0.85 lambda (MP - SP) -0.022914461005779638 0.1350161499242592 0.8664115353890729 0.905811623246493 -2.2653918601394207 20.0 10.0 20386.0 placebo 2
25 crossers 0.85 ell + lambda (multiplayer) 0.1533156020368989 0.05851685664585496 0.013845652108582351 0.014028056112224449 16.569281592173812 20.0 10.0 20386.0 placebo 2
26 crossers 0.70,0.80,0.95 ell single-player 0.006329104879160874 0.08233233043910523 0.9388185528481667 0.9579579579579579 real 3 65.0
27 crossers 0.70,0.80,0.95 ell multiplayer-only -0.0059583438610938885 0.08566461791712103 0.9446331363801392 0.953953953953954 real 3 25.0
28 crossers 0.70,0.80,0.95 ell both 0.08719847247799399 0.055314223063373906 0.11685596035126666 0.14514514514514515 real 3 75.0
29 crossers 0.70,0.80,0.95 mp-only minus sp -0.012287448740288129 0.12504481186773275 0.9218423734196226 0.943943943943944 real 3
30 crossers 0.70,0.80,0.95 both minus sp 0.08086936759878514 0.09537211806148527 0.39770994272513716 0.4394394394394394 real 3
31 crossers 0.60,0.75,0.85,0.90 ell single-player 0.07166992971293004 0.08492424818509708 0.3997938592550334 0.4248496993987976 placebo 3 65.0
32 crossers 0.60,0.75,0.85,0.90 ell multiplayer-only 0.08369987916768806 0.07223515341134175 0.24805830610588142 0.3306613226452906 placebo 3 27.0
33 crossers 0.60,0.75,0.85,0.90 ell both 0.08097278504646685 0.04052070166292885 0.04714012831741732 0.04408817635270541 placebo 3 95.0
34 crossers 0.60,0.75,0.85,0.90 mp-only minus sp 0.012029949454759326 0.10754642649982243 0.9110564624887634 0.9118236472945892 placebo 3
35 crossers 0.60,0.75,0.85,0.90 both minus sp 0.009302855333533111 0.08895211301832538 0.9168196030994746 0.9278557114228457 placebo 3
36 rd 0.70,0.80,0.95 ell single-player 0.22545741499110764 0.1362364880567935 0.09878418663672184 0.18118118118118118 real 3 177.0
37 rd 0.70,0.80,0.95 ell multiplayer-only 0.43028002694371525 0.13348361370462755 0.0013777404581201136 0.01901901901901902 real 3 38.0
38 rd 0.70,0.80,0.95 ell both 0.07930716957903333 0.12198106250822549 0.5159882355360925 0.6256256256256256 real 3 160.0
39 rd 0.70,0.80,0.95 mp-only minus sp 0.20482261195260873 0.1477325368261786 0.1664378534075701 0.22422422422422422 real 3
40 rd 0.70,0.80,0.95 both minus sp -0.14615024541207766 0.11461614865696096 0.20305552021560191 0.22522522522522523 real 3
41 rd 0.60,0.75,0.85,0.90 ell single-player -0.22105247468145903 0.11121985594200143 0.04767305942380484 0.09619238476953908 placebo 3 127.0
42 rd 0.60,0.75,0.85,0.90 ell multiplayer-only 0.2921179444375056 0.12033409256097834 0.015724211753443518 0.03006012024048096 placebo 3 42.0
43 rd 0.60,0.75,0.85,0.90 ell both 0.036533405214211175 0.07519781957403315 0.627402972967396 0.6593186372745491 placebo 3 169.0
44 rd 0.60,0.75,0.85,0.90 mp-only minus sp 0.5131704191189583 0.1583899177891829 0.0013148092559693847 0.012024048096192385 placebo 3
45 rd 0.60,0.75,0.85,0.90 both minus sp 0.2575858798956652 0.12785532757291568 0.04473350853787239 0.1282565130260521 placebo 3
-9
View File
@@ -1,9 +0,0 @@
spec,effect,est,se,ci_low,ci_high,p_cluster,p_boot,obs
rd,"placebo jump, sp",0.038729173504570814,0.05224716905952501,-0.0636752778520982,0.14113362486123984,0.45896139420367765,0.4944944944944945,331008
rd,"real minus placebo, sp",-0.002119147098953385,0.08678998574633341,-0.17222751916176687,0.1679892249638601,0.9805320804208619,0.9769769769769769,331008
rd,"placebo jump, mp minus sp",-0.031610781279016106,0.15232032593231748,-0.3301586201063584,0.26693705754832614,0.8357018459247958,0.8748748748748749,331008
rd,TRIPLE: (mp real-placebo) minus (sp real-placebo),-0.5174571339450283,0.2499685958284159,-1.0073955817687235,-0.02751868612133318,0.039078970434134774,0.0970970970970971,331008
crossers,"placebo jump, sp",-0.005986639366604475,0.027054625608215616,-0.05901370555870708,0.047040426825498124,0.8250184843445094,0.8168168168168168,268627
crossers,"real minus placebo, sp",1.1725106155952166e-05,0.03615493841939818,-0.07085195419586449,0.07087540440817638,0.9997414506586217,0.998998998998999,268627
crossers,"placebo jump, mp minus sp",-0.02918863322850976,0.1106608664730715,-0.24608393151572988,0.18770666505871036,0.792132840879243,0.8138138138138138,268627
crossers,TRIPLE: (mp real-placebo) minus (sp real-placebo),-0.16322637039369314,0.15582790262998333,-0.4686490595484605,0.1421963187610742,0.295684575344922,0.3923923923923924,268627
1 spec effect est se ci_low ci_high p_cluster p_boot obs
2 rd placebo jump, sp 0.038729173504570814 0.05224716905952501 -0.0636752778520982 0.14113362486123984 0.45896139420367765 0.4944944944944945 331008
3 rd real minus placebo, sp -0.002119147098953385 0.08678998574633341 -0.17222751916176687 0.1679892249638601 0.9805320804208619 0.9769769769769769 331008
4 rd placebo jump, mp minus sp -0.031610781279016106 0.15232032593231748 -0.3301586201063584 0.26693705754832614 0.8357018459247958 0.8748748748748749 331008
5 rd TRIPLE: (mp real-placebo) minus (sp real-placebo) -0.5174571339450283 0.2499685958284159 -1.0073955817687235 -0.02751868612133318 0.039078970434134774 0.0970970970970971 331008
6 crossers placebo jump, sp -0.005986639366604475 0.027054625608215616 -0.05901370555870708 0.047040426825498124 0.8250184843445094 0.8168168168168168 268627
7 crossers real minus placebo, sp 1.1725106155952166e-05 0.03615493841939818 -0.07085195419586449 0.07087540440817638 0.9997414506586217 0.998998998998999 268627
8 crossers placebo jump, mp minus sp -0.02918863322850976 0.1106608664730715 -0.24608393151572988 0.18770666505871036 0.792132840879243 0.8138138138138138 268627
9 crossers TRIPLE: (mp real-placebo) minus (sp real-placebo) -0.16322637039369314 0.15582790262998333 -0.4686490595484605 0.1421963187610742 0.295684575344922 0.3923923923923924 268627
-216
View File
@@ -1,216 +0,0 @@
"""
Event study around the first clean crossing of a review-label cutoff.
For each game and cutoff we find the first day t0 where the lagged score S_{t-1} crosses c
(up: from below to above; down: from above to below), requiring a clean crossing:
- PRE_CLEAN days before t0 the score stayed on the old side,
- PERSIST days from t0 the score stayed on the new side.
Then, in a +-EV_WIN day window around t0:
ln(1+R) = event FE + date FE + sum_k b_k * 1[bin(k)=k] (reference bin: -1)
Plots b_k (event-study) and the share of days above the cutoff (first stage).
Also a step estimate: ln(1+R) = post + k + k*post | event FE + date FE.
Expected sign if the label matters: positive for up-crossings, negative for down-crossings.
"""
import numpy as np
import pandas as pd
import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt
import pyfixest as pf
from game_test import load, add_groups, build, boot_p, DATA_GLOB, MIN_REVIEWS
# ----------------------------------------------------------------- settings
EV_WIN = 30 # days before/after the crossing
EV_BIN = 3 # bin width in days (daily data is too noisy)
PRE_CLEAN = 14 # days before crossing that must be on the old side
PERSIST = 7 # days from crossing that must be on the new side (1 = intent-to-treat)
REAL_CUTS = [0.70, 0.80] # 0.95 adds almost no events
PLACEBO_CUTS = [0.75, 0.85] # no label change here
MIN_EVENTS = 15 # skip cells with fewer events
BOOT_REPS = 499
# ----------------------------------------------------------------- events
def find_events(df, cutoffs, direction):
out = []
for sheet, g in df.groupby("sheet"):
g = g.sort_values("date")
grp = g["group"].iloc[0]
g = g.set_index("date")
g = g.reindex(pd.date_range(g.index.min(), g.index.max(), freq="D"))
S, L, N = g["S_lag"].to_numpy(), g["lnR"].to_numpy(), g["N_lag"].to_numpy()
n, dates = len(S), g.index
known = ~np.isnan(S)
for c in cutoffs:
above = S >= c
if direction == "up":
hits = np.where(above[1:] & ~above[:-1] & known[1:] & known[:-1])[0] + 1
else:
hits = np.where(~above[1:] & above[:-1] & known[1:] & known[:-1])[0] + 1
for t in hits:
if t < PRE_CLEAN or t + PERSIST > n or not N[t] >= MIN_REVIEWS:
continue
pre, post = S[t - PRE_CLEAN:t], S[t:t + PERSIST]
pk, qk = ~np.isnan(pre), ~np.isnan(post)
if pk.mean() < 0.7 or qk.mean() < 0.7:
continue
if direction == "up":
ok = (pre[pk] < c).all() and (post[qk] >= c).all()
else:
ok = (pre[pk] >= c).all() and (post[qk] < c).all()
if not ok:
continue
idx = np.arange(max(t - EV_WIN, 0), min(t + EV_WIN, n))
k = idx - t
fr = pd.DataFrame({"sheet": sheet, "group": grp, "cutoff": c,
"eid": f"{sheet}_{c:.2f}", "k": k,
"kb": np.floor_divide(k, EV_BIN),
"lnR": L[idx], "D": above[idx].astype(int),
"date": dates[idx]})
out.append(fr.dropna(subset=["lnR"]))
break # first clean crossing only
return pd.concat(out, ignore_index=True) if out else pd.DataFrame()
# ----------------------------------------------------------------- estimation
def estimate(ev):
ev = ev.copy()
ev["gid"] = pd.factorize(ev["sheet"])[0] # integer cluster id (numba)
ev["eid_i"] = pd.factorize(ev["eid"])[0]
ev["date_i"] = pd.factorize(ev["date"])[0]
ref = -1
names = {}
for b in sorted(ev["kb"].unique()):
if b == ref:
continue
nm = f"k_{'m' if b < 0 else 'p'}{abs(b)}"
ev[nm] = (ev["kb"] == b).astype(int)
names[b] = nm
cl = {"CRV1": "gid"}
m = pf.feols(f"lnR ~ {' + '.join(names.values())} | eid_i + date_i", data=ev, vcov=cl)
t = m.tidy()
coefs = []
for b, nm in names.items():
if nm in t.index:
e, s = float(t.loc[nm, "Estimate"]), float(t.loc[nm, "Std. Error"])
coefs.append((b, e, s))
coefs.append((ref, 0.0, 0.0))
coefs = pd.DataFrame(coefs, columns=["kb", "est", "se"]).sort_values("kb")
ev["post"] = (ev["k"] >= 0).astype(int)
ev["k_post"] = ev["k"] * ev["post"]
ms = pf.feols("lnR ~ post + k + k_post | eid_i + date_i", data=ev, vcov=cl)
ts = ms.tidy()
step = dict(est=float(ts.loc["post", "Estimate"]), se=float(ts.loc["post", "Std. Error"]),
p_cluster=float(ts.loc["post", "Pr(>|t|)"]))
first_stage = ev.groupby("kb")["D"].mean()
return coefs, step, first_stage
def plot(coefs, first_stage, title, path):
fig, (a1, a2) = plt.subplots(2, 1, figsize=(8, 7), sharex=True,
gridspec_kw={"height_ratios": [3, 1.3]})
x = coefs["kb"] * EV_BIN
a1.errorbar(x, coefs["est"], yerr=1.96 * coefs["se"], fmt="o-", capsize=3)
a1.axhline(0, color="grey", lw=0.8)
a1.axvline(-0.5, color="red", ls="--", lw=0.8)
a1.set_ylabel("ln(1+reviews) vs bin -1")
a1.set_title(title)
a2.plot(first_stage.index * EV_BIN, first_stage.values, "s-")
a2.axvline(-0.5, color="red", ls="--", lw=0.8)
a2.set_ylim(0, 1)
a2.set_ylabel("share above cutoff")
a2.set_xlabel(f"days since crossing (bin start, {EV_BIN}-day bins)")
fig.tight_layout()
fig.savefig(path, dpi=150)
plt.close(fig)
def pooled_signed(ev_up, ev_down):
ev = pd.concat([ev_up.assign(sgn=1, dirn="up"),
ev_down.assign(sgn=-1, dirn="down")], ignore_index=True)
ev["eid"] = ev["eid"] + "_" + ev["dirn"]
ev["gid"] = pd.factorize(ev["sheet"])[0]
ev["eid_i"] = pd.factorize(ev["eid"])[0]
ev["date_dir"] = pd.factorize(ev["date"].astype(str) + "_" + ev["dirn"])[0] # date FE per direction
ev["post"] = (ev["k"] >= 0).astype(int)
ev["post_s"] = ev["post"] * ev["sgn"] # +post for up, -post for down
up = (ev["sgn"] == 1).astype(int)
ev["kp_up"] = ev["k"] * ev["post"] * up # linear trend is absorbed by the FEs,
ev["kp_dn"] = ev["k"] * ev["post"] * (1 - up) # only the change at the crossing is identified
m = pf.feols("lnR ~ post_s + kp_up + kp_dn | eid_i + date_dir",
data=ev, vcov={"CRV1": "gid"})
t = m.tidy()
return (float(t.loc["post_s", "Estimate"]), float(t.loc["post_s", "Std. Error"]),
float(t.loc["post_s", "Pr(>|t|)"]), ev["eid"].nunique(), ev["sheet"].nunique())
# ----------------------------------------------------------------- run
if __name__ == "__main__":
import warnings
warnings.filterwarnings("ignore", category=UserWarning, module="pyfixest")
df = build(add_groups(load(DATA_GLOB)))
rows, pooled = [], []
for kind, cuts in [("real", REAL_CUTS), ("placebo", PLACEBO_CUTS)]:
ups, downs = find_events(df, cuts, "up"), find_events(df, cuts, "down")
# ---- pooled signed step (up and down combined)
if not ups.empty and not downs.empty:
e, s, p, n_ev, n_g = pooled_signed(ups, downs)
print(f"{kind}: signed step {e:.4f} (SE {s:.4f}, p {p:.3f}), "
f"{n_ev} events, {n_g} games, {100*(np.exp(e)-1):.1f}%")
pooled.append(dict(kind=kind, est=e, se=s, p_cluster=p, events=n_ev,
games=n_g, pct=100 * (np.exp(e) - 1)))
# ---- per direction and group, with plots
for direction, ev_all in [("up", ups), ("down", downs)]:
if ev_all.empty:
print(f"[{kind} {direction}] no events")
continue
for grp in [None, "sp", "mp", "both"]:
ev = ev_all if grp is None else ev_all[ev_all["group"] == grp]
n_ev = ev["eid"].nunique()
label = f"{kind} {direction} {grp or 'all'}"
if n_ev < MIN_EVENTS:
print(f"[{label}] only {n_ev} events, skipped")
continue
coefs, step, fs = estimate(ev)
rows.append(dict(kind=kind, direction=direction, group=grp or "all",
cutoffs=",".join(f"{c:.2f}" for c in cuts),
events=n_ev, games=ev["sheet"].nunique(),
pct=100 * (np.exp(step["est"]) - 1), **step))
if grp is None:
plot(coefs, fs, f"{kind}: {direction}-crossings of {cuts}, {n_ev} events",
f"event_{kind}_{direction}.png")
fake = [0.725, 0.775, 0.825, 0.875, 0.925]
out = []
for c in fake:
u, d = find_events(df, [c], "up"), find_events(df, [c], "down")
if u.empty or d.empty or u["eid"].nunique() < 10 or d["eid"].nunique() < 10:
print(f"fake {c}: too few events, skipped")
continue
e, s, p, n_ev, n_g = pooled_signed(u, d)
out.append(dict(cutoff=c, est=e, se=s, p=p, events=n_ev))
pl = pd.DataFrame(out)
print(pl.to_string(index=False))
print("real est 0.104 vs placebo estimates above bigger:",
int((pl["est"] > 0.104).sum()), "of", len(pl))
real_est = pooled[0]["est"] # the "real" row, computed in the loop above
print(f"real est {real_est:.3f}; placebo estimates larger: "
f"{int((pl['est'] > real_est).sum())} of {len(pl)}")
pd.set_option("display.float_format", lambda x: f"{x:.4f}")
pd.set_option("display.width", 220)
res = pd.DataFrame(rows).drop(columns=["p_boot"], errors="ignore") # p_boot is broken here
print("\nSTEP ESTIMATES (post = jump at crossing, log points; use p_cluster):")
print(res.to_string(index=False))
res.to_csv("event_results.csv", index=False)
pd.DataFrame(pooled).to_csv("event_pooled.csv", index=False)
print("Saved event_results.csv, event_pooled.csv and event_*.png")
Binary file not shown.

Before

Width:  |  Height:  |  Size: 75 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 70 KiB

-3
View File
@@ -1,3 +0,0 @@
kind,est,se,p_cluster,events,games,pct
real,-0.0030531499178668197,0.023879919807555706,0.8983417020392981,453,336,-0.30484937954750047
placebo,0.022755139724486766,0.019991570973315425,0.25574255842134397,509,382,2.3016012893684934
1 kind est se p_cluster events games pct
2 real -0.0030531499178668197 0.023879919807555706 0.8983417020392981 453 336 -0.30484937954750047
3 placebo 0.022755139724486766 0.019991570973315425 0.25574255842134397 509 382 2.3016012893684934
Binary file not shown.

Before

Width:  |  Height:  |  Size: 79 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 76 KiB

-17
View File
@@ -1,17 +0,0 @@
kind,direction,group,cutoffs,events,games,pct,est,se,p_cluster
real,up,all,"0.70,0.80",199,192,-10.648417880250404,-0.11259123754726014,0.03748381331330474,0.003036175460825463
real,up,sp,"0.70,0.80",82,82,-14.260612766375191,-0.15385787164080356,0.04732229113114258,0.0017222892195427608
real,up,mp,"0.70,0.80",32,31,2.7376781824437035,0.027008739831719256,0.15879294661224932,0.8668382155151342
real,up,both,"0.70,0.80",85,79,-3.732994749991936,-0.038044550503742024,0.06776543903173138,0.5763075029936569
real,down,all,"0.70,0.80",254,251,-7.049311425745519,-0.07310106384103623,0.03046442915180092,0.01714758261768523
real,down,sp,"0.70,0.80",121,121,-9.33502075376833,-0.09799901978819309,0.055758994670060034,0.08150904843863604
real,down,mp,"0.70,0.80",31,30,-4.892878350759378,-0.05016633333897211,0.07007409209758021,0.48193599344217275
real,down,both,"0.70,0.80",102,100,-2.0368671079089684,-0.020578973075265076,0.05809804137107864,0.7239574918770453
placebo,up,all,"0.75,0.85",224,217,-4.279014776164192,-0.04373263023202346,0.029390974114973406,0.13826116656403387
placebo,up,sp,"0.75,0.85",105,101,-3.035523159957687,-0.03082549270284303,0.05606165581277423,0.5837264713818384
placebo,up,mp,"0.75,0.85",26,25,3.8747925642916847,0.03801607021119906,0.0641392053416555,0.5628261450649412
placebo,up,both,"0.75,0.85",93,91,-8.197555648011912,-0.08553126178816213,0.05992048292715752,0.15740188856998882
placebo,down,all,"0.75,0.85",285,282,-6.63200617406835,-0.06862157800421213,0.02636865772058945,0.009755888562036796
placebo,down,sp,"0.75,0.85",154,153,-2.9559639672159577,-0.030005330782900772,0.04066495096595017,0.4617635171572614
placebo,down,mp,"0.75,0.85",30,30,-4.681505709375511,-0.047946330245884024,0.06177954983927433,0.4490182036319892
placebo,down,both,"0.75,0.85",101,99,-5.8047247818605925,-0.05980016258363823,0.0571807133470576,0.29857933071246534
1 kind direction group cutoffs events games pct est se p_cluster
2 real up all 0.70,0.80 199 192 -10.648417880250404 -0.11259123754726014 0.03748381331330474 0.003036175460825463
3 real up sp 0.70,0.80 82 82 -14.260612766375191 -0.15385787164080356 0.04732229113114258 0.0017222892195427608
4 real up mp 0.70,0.80 32 31 2.7376781824437035 0.027008739831719256 0.15879294661224932 0.8668382155151342
5 real up both 0.70,0.80 85 79 -3.732994749991936 -0.038044550503742024 0.06776543903173138 0.5763075029936569
6 real down all 0.70,0.80 254 251 -7.049311425745519 -0.07310106384103623 0.03046442915180092 0.01714758261768523
7 real down sp 0.70,0.80 121 121 -9.33502075376833 -0.09799901978819309 0.055758994670060034 0.08150904843863604
8 real down mp 0.70,0.80 31 30 -4.892878350759378 -0.05016633333897211 0.07007409209758021 0.48193599344217275
9 real down both 0.70,0.80 102 100 -2.0368671079089684 -0.020578973075265076 0.05809804137107864 0.7239574918770453
10 placebo up all 0.75,0.85 224 217 -4.279014776164192 -0.04373263023202346 0.029390974114973406 0.13826116656403387
11 placebo up sp 0.75,0.85 105 101 -3.035523159957687 -0.03082549270284303 0.05606165581277423 0.5837264713818384
12 placebo up mp 0.75,0.85 26 25 3.8747925642916847 0.03801607021119906 0.0641392053416555 0.5628261450649412
13 placebo up both 0.75,0.85 93 91 -8.197555648011912 -0.08553126178816213 0.05992048292715752 0.15740188856998882
14 placebo down all 0.75,0.85 285 282 -6.63200617406835 -0.06862157800421213 0.02636865772058945 0.009755888562036796
15 placebo down sp 0.75,0.85 154 153 -2.9559639672159577 -0.030005330782900772 0.04066495096595017 0.4617635171572614
16 placebo down mp 0.75,0.85 30 30 -4.681505709375511 -0.047946330245884024 0.06177954983927433 0.4490182036319892
17 placebo down both 0.75,0.85 101 99 -5.8047247818605925 -0.05980016258363823 0.0571807133470576 0.29857933071246534
-389
View File
@@ -1,389 +0,0 @@
"""
Label-cutoff RD, run separately for single-player (sp), multiplayer-only (mp),
both, and all games pooled. Self-contained.
Inputs:
game_tags.csv columns: sheet, genres, group ("sp"/"mp"/"both"), price
data/<sheet>.csv columns: date, positive, negative
Install: pip install pandas numpy pyfixest
"""
import os
import numpy as np
import pandas as pd
# ----------------------------------------------------------------- settings
DATA_DIR = "data"
TAGS_FILE = "game_tags.csv"
# game selection
GAME_GENRES = {
'Action', 'Indie', 'Simulation', 'Strategy', 'RPG', 'Early Access',
'Casual', 'Adventure', 'Free To Play', 'Massively Multiplayer',
'Racing', 'Sports', 'Episodic',
}
MIN_SPAN_DAYS = 365 # first to last date
MAX_SPAN_DAYS = 10 * 365
MIN_TOTAL_REVIEWS = 2000 # all reviews in the file
# RD settings
W = 0.01 # window half-width in score; also try 0.01 and 0.03
MIN_REVIEWS = 500 # min cumulative reviews before a game-day is used
TRIM_Q = 0.99 # drop each game's top 1% burst days (None = off)
MIN_GAMES = 10 # per group AND per side of the cutoff
TIME_FE = "month"
CUTOFFS = [0.70, 0.80, 0.95]
PLACEBOS = [0.60, 0.75, 0.85, 0.90]
BOOT_REPS = 999
PLACEBO_REPS = 499
SEED = 42
# ----------------------------------------------------------------- step 1: choose games, load panel
def load_tags():
tags = pd.read_csv(TAGS_FILE, dtype={"sheet": str})
tags["sheet"] = tags["sheet"].str.strip()
tags = tags.drop_duplicates("sheet")
tags["group"] = tags["group"].astype(str).str.strip().str.lower()
if "price" not in tags.columns:
tags["price"] = np.nan
tags["price"] = pd.to_numeric(tags["price"], errors="coerce") # "NA"/blank -> NaN
return tags
def select_and_load(tags):
"""Genre filter, then read each game file once, apply span/review filters,
fill missing days with zero reviews. Returns the daily panel for kept games."""
mask = tags["genres"].fillna("").str.split(";").apply(
lambda gs: any(g.strip() in GAME_GENRES for g in gs))
games = tags[mask]
print(f"tag rows: {len(tags)}, real games (genre filter): {len(games)}")
frames, n_nofile, n_span, n_rev = [], 0, 0, 0
for sheet in games["sheet"]:
path = os.path.join(DATA_DIR, f"{sheet}.csv")
if not os.path.exists(path):
n_nofile += 1
continue
d = pd.read_csv(path, parse_dates=["date"])[["date", "positive", "negative"]]
d[["positive", "negative"]] = (d[["positive", "negative"]]
.apply(pd.to_numeric, errors="coerce").fillna(0).abs())
if d.empty:
n_nofile += 1
continue
span = (d["date"].max() - d["date"].min()).days + 1
if not (MIN_SPAN_DAYS <= span <= MAX_SPAN_DAYS):
n_span += 1
continue
if d["positive"].sum() + d["negative"].sum() < MIN_TOTAL_REVIEWS:
n_rev += 1
continue
full = pd.date_range(d["date"].min(), d["date"].max(), freq="D")
d = (d.groupby("date")[["positive", "negative"]].sum()
.reindex(full, fill_value=0)
.rename_axis("date").reset_index())
d["sheet"] = sheet
frames.append(d)
print(f"dropped: no file/empty {n_nofile}, span {n_span}, reviews {n_rev}; kept {len(frames)}")
if not frames:
raise SystemExit("No games left after filtering")
return pd.concat(frames, ignore_index=True)
def add_groups(df, tags):
df = df.merge(tags[["sheet", "group", "price"]], on="sheet", how="left")
df = df[df["group"].isin(["sp", "mp", "both"])].copy()
df["MP"] = (df["group"] == "mp").astype(int)
df["BOTH"] = (df["group"] == "both").astype(int)
df["no_price"] = df["price"].isna().astype(int)
df["ln_price"] = np.log1p(df["price"].fillna(0))
print("games per group:", df.groupby("group")["sheet"].nunique().to_dict())
return df
def build(df):
df = df.sort_values(["sheet", "date"]).reset_index(drop=True)
df[["positive", "negative"]] = df[["positive", "negative"]].astype(int)
df["R"] = df["positive"] + df["negative"]
g = df.groupby("sheet")
df["cum_pos"] = g["positive"].cumsum()
df["cum_tot"] = g["R"].cumsum()
df["score"] = df["cum_pos"] / df["cum_tot"].replace(0, np.nan)
g = df.groupby("sheet")
df["S_lag"] = g["score"].shift(1)
df["N_lag"] = g["cum_tot"].shift(1)
df["lnR"] = np.log1p(df["R"])
df["ln_N"] = np.log(df["N_lag"].clip(lower=1))
first = g["date"].transform("min") # CSV must start at release
df["age"] = (df["date"] - first).dt.days
df["ln_age"] = np.log1p(df["age"])
df["rel_year"] = first.dt.year.astype(str)
df["month"] = df["date"].dt.to_period("M").astype(str)
if TRIM_Q is not None:
q = df.groupby("sheet")["R"].transform(lambda x: x.quantile(TRIM_Q))
before = len(df)
df = df[df["R"] <= q]
print(f"burst filter dropped {before - len(df)} game-days")
return df.dropna(subset=["S_lag", "N_lag"])
# ----------------------------------------------------------------- RD helpers
def stack(df, cutoffs, spec="rd"):
"""One row per game-day per cutoff, inside the window.
spec="crossers": keep only games seen on both sides of that cutoff in the window."""
base = df[df["N_lag"] >= MIN_REVIEWS]
parts = []
for c in cutoffs:
s = base[(base["S_lag"] - c).abs() <= W].copy()
s["cut"] = f"{c:.3f}"
s["dist"] = s["S_lag"] - c
s["D"] = (s["dist"] >= 0).astype(int)
if spec == "crossers":
crosses = s.groupby("sheet")["D"].nunique() >= 2
s = s[s["sheet"].isin(crosses[crosses].index)]
parts.append(s)
s = pd.concat(parts, ignore_index=True)
if s.empty:
return s
s["dist_x_D"] = s["dist"] * s["D"]
s["gid"] = pd.factorize(s["sheet"])[0] # cluster id
s["gc"] = pd.factorize(s["sheet"] + "_" + s["cut"])[0] # game x cutoff FE
return s
def boot_p(model, param, reps):
"""Wild cluster bootstrap p-value for one coefficient."""
try:
r = model.wildboottest(param=param, reps=reps, seed=SEED)
return float(r["Pr(>|t|)"])
except Exception as e:
print(f" bootstrap failed for {param}: {e}")
return np.nan
def fit_group(df, cutoffs, reps, group, spec="rd"):
"""Label effect (jump D) for one subset: 'sp', 'mp', 'both' or 'all'."""
sub = df if group == "all" else df[df["group"] == group]
s = stack(sub, cutoffs, spec)
if s.empty:
print(f"[{spec}] {group} {cutoffs}: no rows, skipped")
return None
side = s.groupby("D")["sheet"].nunique()
n0, n1 = int(side.get(0, 0)), int(side.get(1, 0))
if min(n0, n1) < MIN_GAMES:
print(f"[{spec}] {group} {cutoffs}: games below/above = {n0}/{n1} "
f"(need {MIN_GAMES}), skipped")
return None
regs = ["D", "dist", "dist_x_D"]
if group == "all":
# separate slopes per group so the pooled jump is not driven by slope differences
for g in ("MP", "BOTH"):
s[f"dist_x_{g}"] = s["dist"] * s[g]
s[f"dist_x_D_x_{g}"] = s["dist_x_D"] * s[g]
regs += [f"dist_x_{g}", f"dist_x_D_x_{g}"]
if spec == "rd":
ctrl = [c for c in ["ln_age", "ln_N", "ln_price", "no_price"] if s[c].nunique() > 1]
if group == "all":
ctrl += [c for c in ["MP", "BOTH"] if s[c].nunique() > 1]
fes = [TIME_FE, "rel_year"] + (["cut"] if s["cut"].nunique() > 1 else [])
else: # crossers: game x cutoff FE absorbs price, release year, group level
ctrl = [c for c in ["ln_age", "ln_N"] if s[c].nunique() > 1]
fes = ["gc", TIME_FE]
import pyfixest as pf
m = pf.feols(f"lnR ~ {' + '.join(regs + ctrl)} | {' + '.join(fes)}",
data=s, vcov={"CRV1": "gid"})
t = m.tidy()
if "D" not in t.index:
print(f"[{spec}] {group}: D dropped as collinear, skipped")
return None
est = float(t.loc["D", "Estimate"])
return pd.DataFrame([dict(
spec=spec, group=group, cutoffs=",".join(f"{c:.2f}" for c in cutoffs),
est=est, se=float(t.loc["D", "Std. Error"]),
p_cluster=float(t.loc["D", "Pr(>|t|)"]),
p_boot=boot_p(m, "D", reps),
pct=100 * (np.exp(est) - 1),
games_below=n0, games_above=n1, obs=int(m._N))])
def test_all_groups(df, cutoffs, reps, spec="rd", per_cutoff=False):
sets = [cutoffs] + ([[c] for c in cutoffs] if per_cutoff else [])
out = [fit_group(df, cs, reps, g, spec)
for cs in sets for g in ("sp", "mp", "both", "all")]
out = [o for o in out if o is not None]
return pd.concat(out, ignore_index=True) if out else None
def fit_did(df, group, spec="rd", reps=BOOT_REPS):
"""Difference-in-discontinuities: real-cutoff jump minus average placebo jump."""
sub = df if group == "all" else df[df["group"] == group]
s = stack(sub, CUTOFFS + PLACEBOS, spec) # real and placebo cutoffs together
if s.empty:
return None
real_cuts = [f"{c:.3f}" for c in CUTOFFS]
s["real"] = s["cut"].isin(real_cuts).astype(int)
# check there are enough games on each side for both kinds of cutoff
side = s.groupby(["real", "D"])["sheet"].nunique()
if side.min() < MIN_GAMES or len(side) < 4:
print(f"[{spec}] {group}: too few games per side {side.to_dict()}, skipped")
return None
s["D_x_real"] = s["D"] * s["real"]
s["dist_x_real"] = s["dist"] * s["real"]
s["dist_x_D_x_real"] = s["dist_x_D"] * s["real"]
regs = ["D", "D_x_real", "dist", "dist_x_D", "dist_x_real", "dist_x_D_x_real"]
if group == "all": # group-specific slopes, as before
for g in ("MP", "BOTH"):
s[f"dist_x_{g}"] = s["dist"] * s[g]
s[f"dist_x_D_x_{g}"] = s["dist_x_D"] * s[g]
regs += [f"dist_x_{g}", f"dist_x_D_x_{g}"]
if spec == "rd":
ctrl = [c for c in ["ln_age", "ln_N", "ln_price", "no_price"] if s[c].nunique() > 1]
if group == "all":
ctrl += [c for c in ["MP", "BOTH"] if s[c].nunique() > 1]
fes = [TIME_FE, "rel_year", "cut"] # "cut" absorbs the real dummy
else:
ctrl = [c for c in ["ln_age", "ln_N"] if s[c].nunique() > 1]
fes = ["gc", TIME_FE]
import pyfixest as pf
m = pf.feols(f"lnR ~ {' + '.join(regs + ctrl)} | {' + '.join(fes)}",
data=s, vcov={"CRV1": "gid"})
t = m.tidy()
rows = []
for label, par in [("placebo jump (D)", "D"),
("real minus placebo (D_x_real)", "D_x_real")]:
est = float(t.loc[par, "Estimate"])
rows.append(dict(spec=spec, group=group, effect=label, est=est,
se=float(t.loc[par, "Std. Error"]),
p_cluster=float(t.loc[par, "Pr(>|t|)"]),
p_boot=boot_p(m, par, reps),
pct=100 * (np.exp(est) - 1),
obs=int(m._N)))
return pd.DataFrame(rows)
def fit_did_mp(df, spec="rd", reps=BOOT_REPS):
"""Triple difference: (mp real-minus-placebo) minus (sp real-minus-placebo)."""
sub = df[df["group"].isin(["sp", "mp"])] # "both" excluded
s = stack(sub, CUTOFFS + PLACEBOS, spec)
if s.empty:
return None
real_cuts = [f"{c:.3f}" for c in CUTOFFS]
s["real"] = s["cut"].isin(real_cuts).astype(int)
# games per cell: MP x real x side of cutoff
cells = s.groupby(["MP", "real", "D"])["sheet"].nunique()
print(f"[{spec}] games per cell (MP, real, D):\n{cells.to_string()}")
if len(cells) < 8 or cells.min() < MIN_GAMES:
print(f"[{spec}] some cell has fewer than {MIN_GAMES} games, skipped")
return None
# jump terms
s["D_x_real"] = s["D"] * s["real"]
s["D_x_MP"] = s["D"] * s["MP"]
s["D_x_real_x_MP"] = s["D"] * s["real"] * s["MP"]
regs = ["D", "D_x_real", "D_x_MP", "D_x_real_x_MP"]
# slopes: fully interacted so slope differences don't leak into the jump
for v in ("dist", "dist_x_D"):
s[f"{v}_x_real"] = s[v] * s["real"]
s[f"{v}_x_MP"] = s[v] * s["MP"]
s[f"{v}_x_real_x_MP"] = s[v] * s["real"] * s["MP"]
regs += [v, f"{v}_x_real", f"{v}_x_MP", f"{v}_x_real_x_MP"]
if spec == "rd":
s["real_x_MP"] = s["real"] * s["MP"]
ctrl = [c for c in ["ln_age", "ln_N", "ln_price", "no_price",
"MP", "real_x_MP"] if s[c].nunique() > 1]
fes = [TIME_FE, "rel_year", "cut"] # "cut" absorbs the real dummy
else: # gc absorbs MP and real x MP
ctrl = [c for c in ["ln_age", "ln_N"] if s[c].nunique() > 1]
fes = ["gc", TIME_FE]
import pyfixest as pf
m = pf.feols(f"lnR ~ {' + '.join(regs + ctrl)} | {' + '.join(fes)}",
data=s, vcov={"CRV1": "gid"})
t = m.tidy()
labels = {"D": "placebo jump, sp",
"D_x_real": "real minus placebo, sp",
"D_x_MP": "placebo jump, mp minus sp",
"D_x_real_x_MP": "TRIPLE: (mp real-placebo) minus (sp real-placebo)"}
rows = []
for par, label in labels.items():
if par not in t.index:
continue
est = float(t.loc[par, "Estimate"])
se = float(t.loc[par, "Std. Error"])
rows.append(dict(spec=spec, effect=label, est=est, se=se,
ci_low=est - 1.96 * se, ci_high=est + 1.96 * se,
p_cluster=float(t.loc[par, "Pr(>|t|)"]),
p_boot=boot_p(m, par, reps),
obs=int(m._N)))
return pd.DataFrame(rows)
# ----------------------------------------------------------------- run
if __name__ == "__main__":
import warnings
warnings.filterwarnings("ignore", category=UserWarning, module="pyfixest")
pd.set_option("display.float_format", lambda x: f"{x:.4f}")
pd.set_option("display.width", 220)
tags = load_tags()
df = build(add_groups(select_and_load(tags), tags))
print(df["sheet"].nunique(), "games with lagged score,",
df[df["N_lag"] >= MIN_REVIEWS]["sheet"].nunique(), f"with {MIN_REVIEWS}+ reviews")
tri = [fit_did_mp(df, spec) for spec in ["rd", "crossers"]]
tri = pd.concat([x for x in tri if x is not None], ignore_index=True)
print(tri.to_string(index=False))
tri.to_csv("ell_triple.csv", index=False)
'''
did = [fit_did(df, g, spec) for spec in ["rd", "crossers"]
for g in ("sp", "mp", "both", "all")]
did = pd.concat([d for d in did if d is not None], ignore_index=True)
print(did.to_string(index=False))
did.to_csv("ell_did.csv", index=False)
res = []
for spec in ["rd", "crossers"]:
print(f"\n=== {spec.upper()} by group: real cutoffs (stacked, plus each cutoff) ===")
real = test_all_groups(df, CUTOFFS, BOOT_REPS, spec, per_cutoff=True)
if real is not None:
print(real.to_string(index=False))
res.append(real.assign(kind="real"))
print(f"\n=== {spec.upper()} by group: placebos ===")
plc = test_all_groups(df, PLACEBOS, PLACEBO_REPS, spec, per_cutoff=True)
if plc is not None:
print(plc.to_string(index=False))
res.append(plc.assign(kind="placebo"))
if res:
pd.concat(res).to_csv("ell_by_group.csv", index=False)
print("Saved ell_by_group.csv")
'''
+100 -4
View File
@@ -58,9 +58,9 @@ sheet,group,name,categories,price,currency,genres
203770,both,Crusader Kings II,Single-player;Multi-player;Steam Trading Cards;Family Sharing,0,,RPG;Simulation;Strategy;Free To Play
2054970,sp,Dragon's Dogma 2,Single-player;Steam Achievements;Steam Trading Cards;Gamepad Recommended;DualShock Controller Support;DualSense Controller Support;Partial Controller Support;Steam Cloud;HDR available;Family Sharing,39.99,USD,Action;RPG
208650,sp,Batman™: Arkham Knight,Single-player;Steam Achievements;Full controller support;Steam Trading Cards;Steam Cloud;Steam Leaderboards;Remote Play on Phone;Remote Play on Tablet;Remote Play on TV;Family Sharing,19.99,USD,Action;Adventure
2113850,sp,Spirit City: Lofi Sessions,Single-player;Steam Achievements;Steam Trading Cards;Steam Cloud;Stats;Family Sharing,11.99,USD,
2116120,both,Incursion Red River,Single-player;Multi-player;Co-op;Online Co-op;Steam Achievements;Steam Cloud;Family Sharing,21.99,USD,
2129530,both,REANIMAL,Single-player;Multi-player;Co-op;Online Co-op;Shared/Split Screen Co-op;Shared/Split Screen;Cross-Platform Multiplayer;Steam Achievements;Full controller support;Steam Trading Cards;Custom Volume Controls;Gamepad Recommended;Playable without Timed Input;DualShock Controller Support;DualSense Controller Support;Stereo Sound;Surround Sound;Steam Cloud;Remote Play Together;HDR available;Family Sharing,39.99,USD,
2113850,sp,Spirit City: Lofi Sessions,Single-player;Steam Achievements;Steam Trading Cards;Steam Cloud;Stats;Family Sharing,11.99,USD,Casual;Indie;Simulation
2116120,both,Incursion Red River,Single-player;Multi-player;Co-op;Online Co-op;Steam Achievements;Steam Cloud;Family Sharing,21.99,USD,Action;Early Access
2129530,both,REANIMAL,Single-player;Multi-player;Co-op;Online Co-op;Shared/Split Screen Co-op;Shared/Split Screen;Cross-Platform Multiplayer;Steam Achievements;Full controller support;Steam Trading Cards;Custom Volume Controls;Gamepad Recommended;Playable without Timed Input;DualShock Controller Support;DualSense Controller Support;Stereo Sound;Surround Sound;Steam Cloud;Remote Play Together;HDR available;Family Sharing,39.99,USD,Adventure
2139460,mp,Once Human,Multi-player;MMO;PvP;Online PvP;Co-op;Online Co-op;Full controller support;Steam Trading Cards;In-App Purchases;DualShock Controller Support;DualShock Controller Support;DualSense Controller Support;DualSense Controller Support;Family Sharing,0,,
214950,both,Total War: ROME II - Emperor Edition,Single-player;Multi-player;PvP;Online PvP;LAN PvP;Co-op;Online Co-op;LAN Co-op;Steam Trading Cards;Camera Comfort;Custom Volume Controls;Adjustable Difficulty;Playable without Timed Input;Save Anytime;Stereo Sound;Surround Sound;Steam Cloud;Family Sharing,29.99,USD,
218620,both,PAYDAY 2,Single-player;Multi-player;Co-op;Online Co-op;Steam Achievements;Full controller support;Tracked Controller Support;VR Supported;Steam Trading Cards;In-App Purchases;Camera Comfort;Custom Volume Controls;Adjustable Difficulty;Playable without Timed Input;DualShock Controller Support;Stereo Sound;Steam Cloud;Remote Play on Phone;Remote Play on Tablet;Remote Play on TV;Family Sharing,9.99,USD,
@@ -243,7 +243,7 @@ sheet,group,name,categories,price,currency,genres
1946560,sp,sobosuba,Single-player;Steam Achievements;Full controller support;DualShock Controller Support;DualShock Controller Support;DualSense Controller Support;DualSense Controller Support;Steam Leaderboards;Family Sharing,3.99,USD,Casual;Indie
2026820,sp,Die in the Dungeon,Single-player;Steam Achievements;Full controller support;DualShock Controller Support;DualShock Controller Support;Steam Cloud;Family Sharing,14.99,USD,Indie;RPG;Strategy
2085540,both,Stick It to the Stickman,Single-player;Multi-player;Co-op;Shared/Split Screen Co-op;Shared/Split Screen;Steam Achievements;Full controller support;Steam Workshop;Gamepad Recommended;DualSense Controller Support;Steam Cloud;Includes level editor;Remote Play Together;Family Sharing,11.99,USD,Action;Indie
2111550,both,Schrodinger's Cat Burglar,Single-player;Multi-player;Co-op;Shared/Split Screen Co-op;Shared/Split Screen;Steam Achievements;Full controller support;Adjustable Text Size;Camera Comfort;Color Alternatives;Custom Volume Controls;Adjustable Difficulty;Gamepad Recommended;Keyboard Only Option;Playable without Timed Input;DualShock Controller Support;DualSense Controller Support;Stereo Sound;Subtitle Options;Steam Cloud;Stats;Remote Play Together;Family Sharing,19.99,USD,
2111550,both,Schrodinger's Cat Burglar,Single-player;Multi-player;Co-op;Shared/Split Screen Co-op;Shared/Split Screen;Steam Achievements;Full controller support;Adjustable Text Size;Camera Comfort;Color Alternatives;Custom Volume Controls;Adjustable Difficulty;Gamepad Recommended;Keyboard Only Option;Playable without Timed Input;DualShock Controller Support;DualSense Controller Support;Stereo Sound;Subtitle Options;Steam Cloud;Stats;Remote Play Together;Family Sharing,19.99,USD,Adventure;Indie
2162800,sp,shapez 2 - Factory,Single-player;Steam Achievements;Steam Workshop;Adjustable Text Size;Camera Comfort;Color Alternatives;#category_contrast_controls;Custom Volume Controls;Adjustable Difficulty;#category_playable_at_your_own_pace;Playable without Timed Input;Save Anytime;Stereo Sound;Subtitle Options;Steam Cloud;Family Sharing,29.99,USD,
2209900,sp,Moonlight Peaks,Single-player;Steam Achievements;Full controller support;Steam Trading Cards;Gamepad Recommended;DualShock Controller Support;DualShock Controller Support;DualSense Controller Support;DualSense Controller Support;Steam Cloud;Family Sharing,34.99,USD,
2245620,sp,Tangy TD,Single-player;Steam Achievements;Steam Cloud;Steam Leaderboards;Family Sharing,9.99,USD,
@@ -3640,3 +3640,99 @@ sheet,group,name,categories,price,currency,genres
2104240,sp,DREDGE - Blackstone Key,Single-player;Downloadable Content;Steam Achievements;Full controller support;Steam Cloud;Family Sharing,4.99,USD,Adventure;RPG
2104890,both,RoadCraft,Single-player;Multi-player;Co-op;Online Co-op;Cross-Platform Multiplayer;Steam Achievements;Full controller support;Steam Trading Cards;Camera Comfort;Custom Volume Controls;Playable without Timed Input;DualShock Controller Support;DualShock Controller Support;DualSense Controller Support;DualSense Controller Support;Save Anytime;Stereo Sound;Surround Sound;Steam Cloud;Family Sharing,39.99,USD,Adventure;Simulation
2105620,sp,Sektori,Single-player;Steam Achievements;Full controller support;Steam Trading Cards;Camera Comfort;Adjustable Difficulty;Gamepad Recommended;DualShock Controller Support;DualShock Controller Support;DualSense Controller Support;DualSense Controller Support;Stereo Sound;Steam Cloud;Steam Leaderboards;Family Sharing,14.99,USD,Action
2105910,both,Garbanzo Quest,Single-player;Multi-player;Co-op;Shared/Split Screen Co-op;Shared/Split Screen;Steam Achievements;Full controller support;Captions available;DualShock Controller Support;DualShock Controller Support;DualSense Controller Support;DualSense Controller Support;Steam Input API Support;Steam Cloud;Includes level editor;Remote Play Together;Family Sharing,19.99,USD,Action;Adventure;Indie
2106520,sp,私のリアルは充実しすぎている フルボイス版,Single-player;Remote Play on Phone;Remote Play on Tablet;Family Sharing,9.99,USD,Adventure;Casual;Indie
2106670,both,Gatekeeper,Single-player;Multi-player;Co-op;Online Co-op;Steam Achievements;Full controller support;Steam Trading Cards;DualShock Controller Support;DualSense Controller Support;Steam Cloud;Family Sharing,14.99,USD,Action;Adventure;Indie
2106810,sp,The Forest of Drizzling Rain,Single-player;Family Sharing,15.99,USD,Adventure;Indie;RPG
2106840,sp,PARANORMASIGHT: The Seven Mysteries of Honjo,Single-player;Steam Achievements;Camera Comfort;Color Alternatives;Custom Volume Controls;Keyboard Only Option;Mouse Only Option;Playable without Timed Input;Save Anytime;Partial Controller Support;Steam Cloud;Family Sharing,19.99,USD,Adventure;RPG;Simulation
2107090,both,KitHack Model Club,Single-player;Multi-player;PvP;Online PvP;Co-op;Online Co-op;Steam Workshop;Adjustable Text Size;Camera Comfort;Color Alternatives;Custom Volume Controls;Playable without Timed Input;DualShock Controller Support;DualShock Controller Support;Save Anytime;Stereo Sound;Surround Sound;Partial Controller Support;Steam Cloud;Includes level editor;Remote Play on TV;Family Sharing,19.99,USD,none
2107670,mp,Warhaven,Multi-player;PvP;Online PvP;In-App Purchases;Partial Controller Support;Family Sharing,NA,,Action;Early Access
2107680,unknown,Warhaven Playtest,Partial Controller Support,NA,,none
2108180,sp,Swordhaven: Iron Conspiracy,Single-player;Steam Achievements;Full controller support;Steam Trading Cards;Steam Workshop;Adjustable Text Size;Camera Comfort;Color Alternatives;Custom Volume Controls;Adjustable Difficulty;Keyboard Only Option;Mouse Only Option;Playable without Timed Input;DualShock Controller Support;DualShock Controller Support;DualSense Controller Support;DualSense Controller Support;Save Anytime;Steam Input API Support;Stereo Sound;Subtitle Options;Steam Cloud;Family Sharing,24.99,USD,Adventure;RPG
2108290,sp,The Impregnation of the Elves: Conquest of the Arrogant Fairies by Impregnation,Single-player;Steam Achievements;Steam Cloud;Family Sharing,10.99,USD,Adventure;Indie;RPG;Simulation;Strategy
2108330,both,F1® 23,Single-player;Multi-player;PvP;Online PvP;Shared/Split Screen PvP;Co-op;Online Co-op;Shared/Split Screen Co-op;Shared/Split Screen;Steam Achievements;Full controller support;VR Supported;Steam Workshop;Gamepad Recommended;DualShock Controller Support;DualSense Controller Support;Steam Cloud;Remote Play Together;HDR available;Family Sharing,NA,,Racing;Sports
2109270,sp,Preserve,Single-player;Steam Achievements;Full controller support;Steam Cloud;Family Sharing,12.49,USD,Casual;Indie
2109300,sp,Resident Evil 4 - Separate Ways,Single-player;Downloadable Content;Steam Achievements;Full controller support;Steam Cloud;Family Sharing,9.99,USD,Action;Adventure
2109370,both,The Great War: Western Front™,Single-player;Multi-player;PvP;Online PvP;Steam Achievements;Steam Trading Cards;Steam Workshop;Steam Cloud;Family Sharing,39.99,USD,Strategy
2109460,sp,VillageRhapsody,Single-player;Steam Achievements;Steam Cloud;Family Sharing,NA,,Casual;Indie;RPG;Simulation
2110110,sp,Motherless - Season 1,Single-player;Steam Achievements;Adjustable Text Size;Custom Volume Controls;Narrated Game Menus;#category_playable_at_your_own_pace;Playable without Timed Input;Save Anytime;Family Sharing,0,,Casual;Indie;Free To Play
2110820,sp,Granny Remake,Single-player;Steam Achievements;Captions available;Partial Controller Support;Family Sharing,6.99,USD,Action;Adventure;Indie
2111170,sp,STORY OF SEASONS: A Wonderful Life,Single-player;Steam Achievements;Steam Trading Cards;DualShock Controller Support;DualShock Controller Support;DualSense Controller Support;DualSense Controller Support;Partial Controller Support;Steam Cloud;Family Sharing,39.99,USD,Casual;RPG;Simulation
2111190,sp,MULLET MADJACK,Single-player;Steam Achievements;Full controller support;Steam Trading Cards;DualShock Controller Support;DualShock Controller Support;DualSense Controller Support;DualSense Controller Support;Steam Input API Support;Steam Cloud;Steam Leaderboards;Family Sharing,19.99,USD,Action;Indie
2111630,sp,JR EAST Train Simulator,Single-player;Full controller support;DualShock Controller Support;DualSense Controller Support;Steam Input API Support;Family Sharing,22.99,USD,Simulation
2111850,both,Gunfire Reborn - Visitors of Spirit Realm,Single-player;Multi-player;Co-op;Online Co-op;Downloadable Content;Steam Achievements;Steam Trading Cards;Partial Controller Support;Steam Cloud;Remote Play on Phone;Remote Play on Tablet;Family Sharing,6.99,USD,Action;Adventure;Indie;RPG
2111870,both,Section 13,Single-player;Multi-player;Co-op;Online Co-op;Full controller support;Steam Cloud;Family Sharing,19.99,USD,Action;Adventure;Indie
2112280,unknown,Men of War II Playtest,,NA,,none
2112520,sp,her tears were my light,Single-player;Steam Achievements;Full controller support;Family Sharing,2.99,USD,Simulation
2113040,sp,RUNGORE,Single-player;Steam Achievements;Full controller support;Steam Cloud;Steam Leaderboards;Family Sharing,14.99,USD,Indie;RPG;Strategy
2113050,sp,RUNGORE: Beginner Experience,Single-player;Steam Achievements;Family Sharing,0,,Adventure;Indie;Strategy
2113430,sp,Soulstone Survivors: Prologue,Single-player;Full controller support;DualShock Controller Support;DualShock Controller Support;DualSense Controller Support;DualSense Controller Support;Steam Cloud;Family Sharing,NA,,Action;Indie;RPG
2113540,sp,梦魇:无归 Nightmare without return,Single-player;Family Sharing,6.99,USD,Adventure;Indie;RPG
2113570,both,Ascend: Reborn,Single-player;Multi-player;PvP;Online PvP;Co-op;Online Co-op;Steam Achievements;Full controller support;In-App Purchases;Steam Leaderboards;Family Sharing,0,,Action;Indie;RPG;Free To Play
2113900,both,Touge Shakai,Single-player;Multi-player;PvP;Online PvP;Steam Achievements;Full controller support;Gamepad Recommended;DualShock Controller Support;DualShock Controller Support;Steam Cloud;Family Sharing,14.99,USD,Indie;Racing;Simulation;Sports;Early Access
2113920,sp,The Legend of Heroes: Kuro no Kiseki Ⅱ -CRIMSON SiN- ,Single-player;Steam Achievements;Gamepad Recommended;DualShock Controller Support;Partial Controller Support;Steam Cloud;Family Sharing,59.99,USD,RPG
2114740,sp,Blasphemous 2,Single-player;Steam Achievements;Full controller support;Gamepad Recommended;DualShock Controller Support;DualShock Controller Support;DualSense Controller Support;DualSense Controller Support;Steam Cloud;Family Sharing,29.99,USD,Action;Adventure;Indie
2114760,both,Crusader Kings III: Friends & Foes,Single-player;Multi-player;PvP;Online PvP;Downloadable Content;Steam Achievements;Steam Trading Cards;Steam Workshop;Steam Cloud;Remote Play on Tablet;Family Sharing,4.99,USD,RPG;Simulation;Strategy
2115390,both,Project Unknown,Single-player;Multi-player;Co-op;Online Co-op;Family Sharing,9.99,USD,Action;Adventure;Indie
2116060,sp,Epic Auto Towers,Single-player;Steam Achievements;Full controller support;DualShock Controller Support;Steam Cloud;Family Sharing,14.99,USD,Casual;Indie;Strategy;Early Access
2118120,both,Kind Words 2 (lofi city pop),Single-player;Multi-player;MMO;PvP;Online PvP;Co-op;Online Co-op;Full controller support;DualShock Controller Support;DualShock Controller Support;DualSense Controller Support;DualSense Controller Support;Steam Cloud;Family Sharing,19.99,USD,Casual;Indie;Massively Multiplayer
2118420,sp,Stories from Sol: The Gun-Dog,Single-player;Steam Achievements;Steam Trading Cards;Partial Controller Support;Steam Cloud;Family Sharing,14.99,USD,Adventure;Indie;RPG
2118810,sp,Breachway,Single-player;Steam Achievements;Full controller support;Steam Trading Cards;DualShock Controller Support;Steam Cloud;Family Sharing,19.99,USD,RPG;Simulation;Strategy;Early Access
2119270,sp,Black Reliquary,Single-player;Full controller support;Steam Cloud;Family Sharing,0,,Indie;RPG;Strategy
2119490,mp,TRAHA Global,Multi-player;MMO;PvP;Online PvP;Co-op;Online Co-op;Cross-Platform Multiplayer;In-App Purchases;Family Sharing,NA,,Action;Massively Multiplayer;RPG;Strategy;Free To Play
2119590,both,Deducto 2,Single-player;Multi-player;PvP;Online PvP;Co-op;Online Co-op;Steam Achievements;DualShock Controller Support;DualShock Controller Support;DualSense Controller Support;DualSense Controller Support;Partial Controller Support;Steam Leaderboards;Family Sharing,4.99,USD,Casual;Indie;Simulation;Strategy
2119740,mp,United heist,Multi-player;Co-op;Online Co-op;Steam Achievements;Family Sharing,0,,Adventure;Indie;Free To Play
2119830,both,MISERY,Single-player;Multi-player;Co-op;Online Co-op;LAN Co-op;Steam Achievements;Custom Volume Controls;Keyboard Only Option;Mouse Only Option;Playable without Timed Input;DualShock Controller Support;DualShock Controller Support;DualSense Controller Support;DualSense Controller Support;Save Anytime;Stereo Sound;Surround Sound;Partial Controller Support;Steam Cloud;Family Sharing,19.99,USD,Action;Adventure;Indie;Massively Multiplayer;Simulation
2120900,sp,Fears to Fathom - Carson House,Single-player;Steam Achievements;Family Sharing,4.99,USD,Adventure;Casual;Indie
2121150,mp,Chess for idiots,Multi-player;PvP;Online PvP;Shared/Split Screen PvP;Shared/Split Screen;Steam Achievements;Captions available;Stats;Remote Play Together;Family Sharing,0,,Casual;Indie;Strategy;Early Access
2121360,sp,东北之夏,Single-player;Steam Achievements;Steam Cloud;Family Sharing,0,,Free To Play;RPG
2121510,sp,Tenebris Somnia,Single-player;Steam Achievements;Full controller support;Steam Trading Cards;Steam Cloud;Family Sharing,24.99,USD,Adventure;Indie
2121980,sp,Void Stranger,Single-player;Full controller support;Steam Cloud;Family Sharing,11.99,USD,Adventure;Indie
2123640,sp,Hollowbody,Single-player;Steam Achievements;Full controller support;Gamepad Recommended;DualShock Controller Support;DualShock Controller Support;DualSense Controller Support;DualSense Controller Support;Steam Cloud;Family Sharing,16.99,USD,Adventure;Indie
2124100,sp,Transience,Single-player;Steam Achievements;Full controller support;Adjustable Text Size;Camera Comfort;Custom Volume Controls;Adjustable Difficulty;Playable without Timed Input;Stereo Sound;Subtitle Options;Surround Sound;Steam Cloud;Family Sharing,19.99,USD,Action;Indie
2124120,sp,SULFUR,Single-player;Steam Achievements;Full controller support;DualShock Controller Support;Steam Input API Support;Steam Cloud;Family Sharing,29.99,USD,Action;Adventure;Indie;RPG;Simulation
2124380,sp,Super Lesbian Animal RPG,Single-player;Partial Controller Support;Steam Cloud;Family Sharing,14.99,USD,Indie;RPG
2124420,sp,Fate Seeker: Journey,Single-player;Steam Achievements;Full controller support;DualShock Controller Support;DualShock Controller Support;DualSense Controller Support;DualSense Controller Support;Steam Cloud;Family Sharing,10.0,USD,Action;RPG
2124490,sp,SILENT HILL 2,Single-player;Steam Achievements;Full controller support;Gamepad Recommended;DualShock Controller Support;DualSense Controller Support;DualSense Controller Support;Steam Cloud;Family Sharing,69.99,USD,Action;Adventure
2124750,both,Stormworks: Industrial Frontier,Single-player;Multi-player;PvP;Online PvP;Co-op;Online Co-op;Downloadable Content;Steam Workshop;Partial Controller Support;Family Sharing,9.99,USD,Simulation
2124780,sp,Endoparasitic,Single-player;Steam Achievements;Steam Workshop;Steam Cloud;Family Sharing,9.99,USD,Indie
2124930,both,Gum Ball Run,Single-player;Multi-player;PvP;Online PvP;Steam Achievements;Partial Controller Support;Steam Leaderboards;Family Sharing,0,,Action;Racing;Free To Play
2125540,sp,Kādomon: Hyper Auto Battlers,Single-player;Full controller support;DualShock Controller Support;DualSense Controller Support;Family Sharing,9.99,USD,Casual;Indie;Simulation;Strategy
2125770,sp,Beeny,Single-player;Partial Controller Support;Family Sharing,0.99,USD,Action
2126190,sp,Rue Valley,Single-player;Steam Achievements;Steam Trading Cards;Captions available;DualShock Controller Support;Partial Controller Support;Steam Cloud;Family Sharing,14.99,USD,Adventure;Casual;Indie
2126550,unknown,The Outlast Trials Playtest,,NA,,none
2126680,sp,Lust Academy - Season 2,Single-player;Steam Achievements;Color Alternatives;Custom Volume Controls;Keyboard Only Option;Mouse Only Option;Playable without Timed Input;Save Anytime;Subtitle Options;Touch Only Option;Steam Cloud;Family Sharing,14.99,USD,Adventure;Casual;Indie
2127010,sp,Handyman Legend,Single-player;Steam Achievements;Steam Cloud;Family Sharing,6.99,USD,Casual;Indie;RPG;Simulation
2128270,sp,Path of Achra,Single-player;Steam Achievements;Steam Cloud;Family Sharing,9.99,USD,RPG
2128480,sp,Staffer Case: A Supernatural Mystery Adventure,Single-player;Steam Achievements;Full controller support;Steam Trading Cards;Steam Cloud;Family Sharing,16.99,USD,Adventure
2128940,mp,THE 4 SINS,Multi-player;Co-op;Online Co-op;Steam Achievements;Steam Workshop;Family Sharing,9.99,USD,Adventure;Indie;RPG;Strategy
2129810,sp,Reignbreaker,Single-player;Steam Achievements;Full controller support;Steam Trading Cards;Gamepad Recommended;DualShock Controller Support;DualShock Controller Support;DualSense Controller Support;DualSense Controller Support;Steam Cloud;Family Sharing,9.99,USD,Action;Adventure;Indie;RPG
2130460,sp,FATAL FRAME / PROJECT ZERO: Mask of the Lunar Eclipse,Single-player;Steam Achievements;Partial Controller Support;Steam Cloud;Family Sharing,49.99,USD,Adventure
2130540,sp,目盲/Blind,Single-player;Steam Achievements;Family Sharing,2.99,USD,Adventure;Casual;RPG;Simulation
2131200,sp,NeverSynth,Single-player;Steam Workshop;Steam Cloud;Family Sharing,11.99,USD,Action;Indie;Racing;Sports
2131350,both,My Coworker is an Idiot,Single-player;Multi-player;Co-op;Online Co-op;Shared/Split Screen Co-op;Shared/Split Screen;Steam Achievements;Remote Play Together;Family Sharing,1.99,USD,Action;Casual;Indie;Simulation
2131630,sp,METAL GEAR SOLID - Master Collection Version,Single-player;Steam Achievements;Full controller support;Gamepad Recommended;DualShock Controller Support;DualSense Controller Support;Family Sharing,19.99,USD,Action
2131640,sp,METAL GEAR SOLID 2: Sons of Liberty - Master Collection Version,Single-player;Steam Achievements;Full controller support;Gamepad Recommended;DualShock Controller Support;Family Sharing,19.99,USD,Action
2131650,sp,METAL GEAR SOLID 3: Snake Eater - Master Collection Version,Single-player;Steam Achievements;Full controller support;Gamepad Recommended;DualShock Controller Support;Family Sharing,19.99,USD,Action
2131680,sp,METAL GEAR & METAL GEAR 2: Solid Snake,Single-player;Steam Achievements;Full controller support;Gamepad Recommended;DualShock Controller Support;Family Sharing,19.99,USD,Action
2132690,sp,Vivat Slovakia,Single-player;Steam Achievements;Full controller support;DualShock Controller Support;DualShock Controller Support;DualSense Controller Support;DualSense Controller Support;Steam Cloud;Family Sharing,19.99,USD,Action;Adventure
2132850,both,Rabbit and Steel,Single-player;Multi-player;Co-op;Online Co-op;Shared/Split Screen Co-op;Shared/Split Screen;Steam Achievements;Full controller support;DualShock Controller Support;DualShock Controller Support;DualSense Controller Support;DualSense Controller Support;Steam Cloud;Remote Play Together;Family Sharing,14.99,USD,Action;Adventure;Indie;RPG
2132890,sp,Possessor(s),Single-player;Steam Achievements;Full controller support;Gamepad Recommended;DualShock Controller Support;DualSense Controller Support;Steam Cloud;Family Sharing,9.99,USD,Action;Adventure
2133670,sp,Perseus: Titan Slayer - Free Trial,Single-player;Steam Achievements;Partial Controller Support;Family Sharing,NA,,Action;Adventure;Indie;RPG
2133760,sp,Tiny Bookshop,Single-player;Steam Achievements;Full controller support;Color Alternatives;Custom Volume Controls;Mouse Only Option;Playable without Timed Input;DualShock Controller Support;DualShock Controller Support;DualSense Controller Support;DualSense Controller Support;Stereo Sound;Touch Only Option;Steam Cloud;Family Sharing,19.99,USD,Casual;Indie;RPG;Simulation
2134320,sp,ENA: Dream BBQ,Single-player;Steam Achievements;Full controller support;Adjustable Text Size;Camera Comfort;Custom Volume Controls;Playable without Timed Input;DualSense Controller Support;Stereo Sound;Steam Cloud;Family Sharing,0,,Adventure;Indie
2134770,sp,SteamWorld Build,Single-player;Steam Achievements;Full controller support;DualShock Controller Support;DualShock Controller Support;DualSense Controller Support;DualSense Controller Support;Steam Cloud;Family Sharing,24.99,USD,Simulation;Strategy
2135150,sp,Elin,Single-player;Steam Achievements;Steam Workshop;Steam Cloud;Family Sharing,19.99,USD,Indie;RPG;Simulation;Strategy;Early Access
2135690,sp,Ticy Adventure Club,Single-player;Family Sharing,0,,Adventure;Indie;RPG;Free To Play
2137700,sp,I'm on Observation Duty 6,Single-player;Steam Achievements;Full controller support;DualShock Controller Support;DualShock Controller Support;DualSense Controller Support;DualSense Controller Support;Family Sharing,11.99,USD,Indie
2137760,sp,Crafty Survivors,Single-player;Steam Achievements;Full controller support;Steam Cloud;Family Sharing,11.99,USD,Action
2138330,sp,Cyberpunk 2077: Phantom Liberty,Single-player;Downloadable Content;Steam Achievements;Full controller support;Steam Trading Cards;Adjustable Text Size;Camera Comfort;Color Alternatives;Custom Volume Controls;Adjustable Difficulty;DualShock Controller Support;DualSense Controller Support;DualSense Controller Support;Save Anytime;Stereo Sound;Subtitle Options;Surround Sound;Steam Cloud;HDR available;Family Sharing,29.99,USD,RPG
2138350,unknown,,,NA,,none
2138450,sp,The Agnietta ~The holy healer & the cursed dungeon~,Single-player;Steam Cloud;Family Sharing,9.99,USD,Action;Adventure;RPG
2138580,sp,Exotica: Petshop Simulator,Single-player;Steam Cloud;Family Sharing,7.99,USD,Casual;Indie;Simulation
2138610,sp,The Legend of Heroes: Trails through Daybreak,Single-player;Steam Achievements;Full controller support;Steam Trading Cards;Adjustable Text Size;Custom Volume Controls;Adjustable Difficulty;DualShock Controller Support;DualShock Controller Support;DualSense Controller Support;DualSense Controller Support;Save Anytime;Stereo Sound;Steam Cloud;HDR available;Family Sharing;Steam Timeline,59.99,USD,Action;Adventure;RPG
2138700,sp,Crypt,Single-player;Steam Achievements;Family Sharing,0,,Adventure;Free To Play;Indie
2138710,sp,Sifu,Single-player;Steam Achievements;Full controller support;DualShock Controller Support;DualShock Controller Support;DualSense Controller Support;DualSense Controller Support;Steam Cloud;Family Sharing,39.99,USD,Action;Indie
2138720,mp,REMATCH,Multi-player;Co-op;Online Co-op;Cross-Platform Multiplayer;Steam Achievements;Full controller support;In-App Purchases;Gamepad Recommended;DualShock Controller Support;DualShock Controller Support;DualSense Controller Support;DualSense Controller Support;Family Sharing,39.99,USD,Action;Indie;Sports
2139020,both,What the Fog,Single-player;Multi-player;Co-op;Online Co-op;Steam Achievements;Full controller support;Family Sharing,4.99,USD,Action
2139300,sp,Redemption Reapers,Single-player;Steam Achievements;Full controller support;Steam Cloud;Family Sharing,24.99,USD,Simulation
Can't render this file because it is too large.
-123
View File
@@ -1,123 +0,0 @@
#!/usr/bin/env python3
"""
Look up Steam prices via the IsThereAnyDeal (ITAD) API using Steam app IDs.
Usage:
export ITAD_API_KEY=your_key_here
python3 itad.py 3330
python3 itad.py 730 1245620 -c DK
python3 itad.py 730 --json
API key: https://isthereanydeal.com/apps/my/
"""
import argparse
import json
import os
import sys
import requests
BASE = "https://api.isthereanydeal.com"
STEAM_SHOP_ID = 61 # Steam's shop ID on ITAD
session = requests.Session()
session.headers.update({
"User-Agent": "itad-price-script/1.0 (+python-requests)",
"Accept": "application/json",
})
def api(method: str, path: str, key: str, params: dict | None = None, body=None):
"""Call the ITAD API; on failure print the status and response body, then exit."""
params = {"key": key, **(params or {})}
try:
r = session.request(method, f"{BASE}{path}", params=params, json=body, timeout=20)
except requests.RequestException as e:
sys.exit(f"Network error: {e}")
if not r.ok:
text = r.text.strip().replace(key, "<key>")
sys.exit(
f"HTTP {r.status_code} from {path}\n{text[:500]}\n"
"Hints: 403 = bad/inactive API key or blocked request; "
"401 = key missing; 429 = rate limited."
)
return r.json()
def lookup_game(key: str, appid: int) -> dict | None:
"""Steam app ID -> ITAD game record."""
data = api("GET", "/games/lookup/v1", key, {"appid": appid})
return data["game"] if data.get("found") else None
def get_steam_prices(key: str, itad_ids: list[str], country: str) -> dict:
"""ITAD game IDs -> {id: current Steam deal or None}."""
data = api(
"POST", "/games/prices/v3", key,
{"country": country, "shops": STEAM_SHOP_ID},
body=itad_ids,
)
return {e["id"]: (e.get("deals") or [None])[0] for e in data}
def main() -> int:
p = argparse.ArgumentParser(description="Steam price lookup via IsThereAnyDeal")
p.add_argument("appids", nargs="+", type=int, help="Steam app ID(s)")
p.add_argument("-c", "--country", default="US", help="2-letter country code (default: US)")
p.add_argument("-k", "--key", default=os.environ.get("ITAD_API_KEY"),
help="ITAD API key (or set ITAD_API_KEY)")
p.add_argument("--json", action="store_true", help="Output JSON")
args = p.parse_args()
if not args.key:
print("Missing API key. Set ITAD_API_KEY or pass --key.", file=sys.stderr)
return 1
games = {}
for appid in args.appids:
game = lookup_game(args.key, appid)
if game:
games[appid] = game
else:
print(f"[{appid}] not found on ITAD", file=sys.stderr)
if not games:
return 1
prices = get_steam_prices(args.key, [g["id"] for g in games.values()], args.country)
results = []
for appid, game in games.items():
deal = prices.get(game["id"])
if not deal:
results.append({"appid": appid, "title": game["title"], "available": False})
continue
results.append({
"appid": appid,
"title": game["title"],
"available": True,
"price": deal["price"]["amount"],
"list_price": deal["regular"]["amount"],
"discount_percent": deal["cut"],
"currency": deal["price"]["currency"],
"url": deal.get("url"),
})
if args.json:
print(json.dumps(results, indent=2))
return 0
for r in results:
print(f"{r['title']} (app {r['appid']})")
if not r["available"]:
print(" No Steam price available for this region\n")
continue
cur = r["currency"]
print(f" Price: {r['price']:.2f} {cur}")
print(f" List price: {r['list_price']:.2f} {cur}")
print(f" Discount: {r['discount_percent']}%\n")
return 0
if __name__ == "__main__":
sys.exit(main())
-133
View File
@@ -1,133 +0,0 @@
"""
Download classification, price and genres for every game in data/.
- Game ids come from the file names in data/ (e.g. data/730.csv -> app id 730).
- A row is complete when it has price AND genres. Incomplete or missing rows are (re)fetched,
so the script can be stopped and re-run, and old files without a genres column are upgraded.
- Writes game_tags.csv: sheet, group, name, categories, price, currency, genres
group = sp / mp / both / unknown (from Steam store "categories")
price = base price before discount, 0 if free, "NA" if no price listed
genres = Steam store genres joined by ";" ("none" if the store lists none)
Install: pip install requests
"""
import csv
import glob
import os
import time
import requests
DATA_GLOB = "data/*.csv"
OUT = "game_tags.csv"
API = "https://store.steampowered.com/api/appdetails"
CC = "us"
DELAY = 1.6
SAVE_EVERY = 10
FIELDS = ["sheet", "group", "name", "categories", "price", "currency", "genres"]
MP_CATS = {"multi-player", "co-op", "online co-op", "pvp", "online pvp", "mmo",
"cross-platform multiplayer"}
SP_CATS = {"single-player"}
def ids_from_files():
ids = []
for path in sorted(glob.glob(DATA_GLOB)):
stem = os.path.splitext(os.path.basename(path))[0]
if stem.isdigit():
ids.append(stem)
else:
print(f"skipping {path}: file name is not a numeric app id")
return ids
def load_rows():
"""Existing rows keyed by sheet; columns missing in an old file load as blanks."""
if not os.path.exists(OUT):
return {}
with open(OUT, newline="", encoding="utf-8") as f:
return {row["sheet"]: {k: row.get(k) or "" for k in FIELDS} for row in csv.DictReader(f)}
def save_rows(rows):
tmp = OUT + ".tmp"
with open(tmp, "w", newline="", encoding="utf-8") as f:
writer = csv.DictWriter(f, fieldnames=FIELDS)
writer.writeheader()
writer.writerows(rows.values())
os.replace(tmp, OUT)
def fetch(appid):
"""Store data dict, {} if Steam has no store entry, None on a temporary failure."""
for attempt in range(5):
try:
r = requests.get(API, params={"appids": appid, "l": "english", "cc": CC}, timeout=20)
if r.status_code == 429:
time.sleep(60 * (attempt + 1))
continue
r.raise_for_status()
entry = r.json()[appid]
return entry["data"] if entry.get("success") else {}
except (requests.RequestException, ValueError, KeyError, TypeError):
time.sleep(5 * (attempt + 1))
return None
def classify(categories):
cats = {c.lower() for c in categories}
mp, sp = bool(cats & MP_CATS), bool(cats & SP_CATS)
if mp and sp:
return "both"
if mp:
return "mp"
if sp:
return "sp"
return "unknown"
def get_price(data):
if data.get("is_free"):
return 0, ""
po = data.get("price_overview")
if po:
return round(po["initial"] / 100, 2), po.get("currency", "")
return "NA", ""
def needs_fetch(rows, appid):
r = rows.get(appid)
return r is None or r["price"] == "" or r["genres"] == ""
def main():
ids = ids_from_files()
rows = load_rows()
todo = [i for i in ids if needs_fetch(rows, i)]
print(f"{len(ids)} games in data/, {len(ids) - len(todo)} complete, {len(todo)} to fetch "
f"(about {len(todo) * DELAY / 60:.0f} min)")
try:
for n, appid in enumerate(todo, 1):
data = fetch(appid)
if data is None:
print(f"[{n}/{len(todo)}] {appid}: request failed, will retry on next run")
continue
cats = [c["description"] for c in data.get("categories", [])]
genres = [g["description"] for g in data.get("genres", [])]
price, currency = get_price(data)
rows[appid] = {"sheet": appid, "group": classify(cats), "name": data.get("name", ""),
"categories": ";".join(cats), "price": price, "currency": currency,
"genres": ";".join(genres) or "none"}
print(f"[{n}/{len(todo)}] {appid} {data.get('name', '?')}: {rows[appid]['group']}, "
f"{price} {currency}, {rows[appid]['genres']}")
if n % SAVE_EVERY == 0:
save_rows(rows)
time.sleep(DELAY)
finally:
save_rows(rows)
if __name__ == "__main__":
main()
-8832
View File
File diff suppressed because it is too large Load Diff
-188
View File
@@ -1,188 +0,0 @@
#!/usr/bin/env python3
"""
Scan Steam app IDs, fetch review metadata, and save the IDs whose positive-review
percentage is near a target (default 20 / 40 / 70) with at least N reviews (default 500).
Usage examples:
python steam_scan.py --start 10 --end 3000000 --step 10
python steam_scan.py --ids-file my_ids.txt # one appid per line instead of incrementing
python steam_scan.py --targets 20 40 70 --tolerance 2 --min-reviews 1000
Output (in --out, default ./steam_out):
interesting.csv matching games (appended as found)
state.json checkpoint, so re-running resumes where it stopped
"""
import argparse
import csv
import json
import os
import sys
import time
import requests
URL = "https://store.steampowered.com/appreviews/{appid}"
FIELDS = ["appid", "bucket", "pct_positive", "positive", "negative",
"total", "review_score_desc", "store_url"]
def fetch_summary(session, appid, retries=6):
"""Return the query_summary dict, or None if the app doesn't exist / has no data."""
wait = 5
for _ in range(retries):
try:
r = session.get(
URL.format(appid=appid),
params={"json": 1, "language": "all", "purchase_type": "all",
"num_per_page": 0, "filter": "all"},
timeout=20,
)
except requests.RequestException:
time.sleep(wait)
wait = min(wait * 2, 300)
continue
if r.status_code == 429: # rate limited -> back off
print(f" rate limited, sleeping {wait}s", file=sys.stderr)
time.sleep(wait)
wait = min(wait * 2, 300)
continue
if r.status_code != 200:
return None
try:
data = r.json()
except ValueError:
return None
if data.get("success") != 1:
return None
return data.get("query_summary")
raise RuntimeError(f"Giving up on appid {appid} after {retries} retries")
def pick_bucket(pct, targets, tol):
best = min(targets, key=lambda t: abs(pct - t))
return best if abs(pct - best) <= tol else None
def load_state(path):
if os.path.exists(path):
with open(path) as f:
return json.load(f)
return {"last_id": None}
def save_state(path, last_id):
tmp = path + ".tmp"
with open(tmp, "w") as f:
json.dump({"last_id": last_id}, f)
os.replace(tmp, path)
def id_stream(args, last_id):
if args.ids_file:
with open(args.ids_file) as f:
ids = [int(line.strip()) for line in f if line.strip().isdigit()]
if last_id is not None:
ids = [i for i in ids if i > last_id]
yield from ids
else:
start = args.start if last_id is None else max(args.start, last_id + args.step)
yield from range(start, args.end, args.step)
def main():
p = argparse.ArgumentParser()
p.add_argument("--start", type=int, default=10)
p.add_argument("--end", type=int, default=3_000_000)
p.add_argument("--step", type=int, default=10, help="Steam app IDs are almost all multiples of 10")
p.add_argument("--ids-file", help="read app IDs from a file instead of incrementing")
p.add_argument("--targets", type=float, nargs="+", default=[20, 40, 70])
p.add_argument("--tolerance", type=float, default=10.0, help="+/- percentage points")
p.add_argument("--min-reviews", type=int, default=500)
p.add_argument("--delay", type=float, default=1.0, help="seconds between requests")
p.add_argument("--out", default="steam_out")
args = p.parse_args()
os.makedirs(args.out, exist_ok=True)
csv_path = os.path.join(args.out, "interesting.csv")
state_path = os.path.join(args.out, "state.json")
state = load_state(state_path)
last_id = state["last_id"]
if last_id is not None:
print(f"Resuming after appid {last_id}")
new_file = not os.path.exists(csv_path)
session = requests.Session()
session.headers["User-Agent"] = "steam-review-scan/1.0"
found = scanned = 0
current = last_id
# per-bucket match counters (seeded from the CSV so they survive a resume)
bucket_counts = {t: 0 for t in args.targets}
if not new_file:
with open(csv_path, newline="") as rf:
for row in csv.DictReader(rf):
try:
b = float(row["bucket"])
except (KeyError, ValueError):
continue
if b in bucket_counts:
bucket_counts[b] += 1
def counter_line(appid):
per_bucket = " ".join(f"{t:g}%:{n}" for t, n in bucket_counts.items())
return f"scanned {scanned} | appid {appid} | matches {found} this run | saved [{per_bucket}]"
with open(csv_path, "a", newline="") as f:
writer = csv.DictWriter(f, fieldnames=FIELDS)
if new_file:
writer.writeheader()
try:
for appid in id_stream(args, last_id):
current = appid
summary = fetch_summary(session, appid)
scanned += 1
if summary:
pos = summary.get("total_positive", 0)
neg = summary.get("total_negative", 0)
total = pos + neg
if total >= args.min_reviews:
pct = 100 * pos / total
bucket = pick_bucket(pct, args.targets, args.tolerance)
if bucket is not None:
writer.writerow({
"appid": appid, "bucket": bucket,
"pct_positive": round(pct, 1),
"positive": pos, "negative": neg, "total": total,
"review_score_desc": summary.get("review_score_desc", ""),
"store_url": f"https://store.steampowered.com/app/{appid}/",
})
f.flush()
found += 1
bucket_counts[bucket] += 1
sys.stdout.write("\r" + " " * 100 + "\r") # clear live counter line
print(f"[MATCH] {appid}: {pct:.1f}% of {total} reviews (target {bucket:g}%)")
if scanned % 50 == 0:
save_state(state_path, appid)
sys.stdout.write("\r" + counter_line(appid)) # live counter
sys.stdout.flush()
time.sleep(args.delay)
except KeyboardInterrupt:
print("\nInterrupted.")
except RuntimeError as e:
print(e, file=sys.stderr)
finally:
if current is not None:
# resume from the last fully processed id
save_state(state_path, current)
print()
print(f"Done. Scanned {scanned}, saved {found} new matches to {csv_path}")
for t, n in bucket_counts.items():
print(f" {t:g}% bucket: {n} total saved")
if __name__ == "__main__":
main()
-169
View File
@@ -1,169 +0,0 @@
import glob
import os
import numpy as np
import pandas as pd
import pyfixest as pf
THRESH = 0.95
CLIP_Q = 0.995 # winsorize, don't drop
DATA_GLOB = "data/*.csv"
TAGS_FILE = "game_tags.csv"
W = 0.02 # window half-width in score; also try 0.01 and 0.03
MIN_REVIEWS = 500
def load(pattern):
frames = []
for path in glob.glob(pattern):
d = pd.read_csv(path, parse_dates=["date"])[["date", "positive", "negative"]].copy()
if d.empty:
print(f"skipping {path}: no rows")
continue
full = pd.date_range(d["date"].min(), d["date"].max(), freq="D")
d = (d.groupby("date")[["positive", "negative"]].sum()
.reindex(full, fill_value=0)
.rename_axis("date").reset_index())
d["sheet"] = os.path.splitext(os.path.basename(path))[0]
frames.append(d)
if not frames:
raise SystemExit(f"No files found for {pattern}")
df = pd.concat(frames, ignore_index=True)
print(len(frames), "files loaded,", df["sheet"].nunique(), "games")
return df
def add_groups(df):
tags = pd.read_csv(TAGS_FILE, dtype={"sheet": str})[["sheet", "group", "price"]].drop_duplicates("sheet")
tags["sheet"] = tags["sheet"].str.strip()
tags["group"] = tags["group"].astype(str).str.strip().str.lower()
tags["price"] = pd.to_numeric(tags["price"], errors="coerce") # "NA" / blank -> NaN
df["sheet"] = df["sheet"].astype(str)
df = df.merge(tags, on="sheet", how="left")
print("Games per group:", df.groupby("group")["sheet"].nunique().to_dict())
missing = df.loc[df["group"].isna(), "sheet"].nunique()
if missing:
print(f"WARNING: {missing} games have no entry in {TAGS_FILE} and are dropped")
return df
def build(df):
cols = ["positive", "negative"]
df[cols] = df[cols].apply(pd.to_numeric, errors="coerce").fillna(0).abs().astype(int)
df = df.sort_values(["sheet", "date"]).reset_index(drop=True)
df["R"] = df["positive"] + df["negative"]
g = df.groupby("sheet")
df["cum_pos"] = g["positive"].cumsum()
df["cum_tot"] = g["R"].cumsum()
df["score"] = df["cum_pos"] / df["cum_tot"].replace(0, np.nan)
# lagged label state (what the store page showed at the start of the day)
g = df.groupby("sheet")
df["S_lag"] = g["score"].shift(1)
df["N_lag"] = g["cum_tot"].shift(1)
# winsorize bursts per game
cap = df.groupby("sheet")["R"].transform(lambda x: x.quantile(CLIP_Q))
df["R_w"] = df["R"].clip(upper=cap)
# baseline: mean reviews/day over days -120..-30 (ends well before today)
df["base"] = (df.groupby("sheet")["R_w"]
.transform(lambda x: x.shift(30).rolling(90, min_periods=60).mean()))
df["y"] = df["R_w"] / df["base"].where(df["base"] > 0.2) # min baseline
df["ly"] = np.log1p(df["y"])
return df.dropna(subset=["S_lag", "N_lag", "ly"])
def rd(df, thresh=THRESH, w=W):
d = df[(df["N_lag"] >= MIN_REVIEWS) & ((df["S_lag"] - thresh).abs() <= w)].copy()
d["x"] = d["S_lag"] - thresh
d["above"] = (d["x"] >= 0).astype(int)
d["xa"] = d["x"] * d["above"]
# date FE = your cross-sectional normalization; cluster by game
m = pf.feols("ly ~ above + x + xa | date", data=d, vcov={"CRV1": "sheet"})
return m
TIERS = [0.20, 0.40, 0.70, 0.80, 0.95] # label cutoffs (500+ review regime)
def add_label(df):
df = df.sort_values(["sheet", "date"]).copy()
pct = (df["S_lag"] * 100).round() / 100 # Steam shows rounded %
df["L"] = np.searchsorted(TIERS, pct.values, side="right")
df.loc[df["N_lag"] < MIN_REVIEWS, "L"] = np.nan # ignore low-count regime
g = df.groupby("sheet")["L"]
df["dL"] = g.diff()
return df
def stack(df, pre=56, post=56, gap=70, ncontrol=60, seed=0):
rng = np.random.default_rng(seed)
flips = df[df["dL"].fillna(0) != 0][["sheet", "date", "dL"]]
flip_by_game = {s: d["date"].values for s, d in flips.groupby("sheet")}
games = {s: d.set_index("date")["R_w"] for s, d in df.groupby("sheet")}
out = []
for k, (_, e) in enumerate(flips.iterrows()):
t0 = e["date"]
# clean event: no other flip for this game within +-gap days
fl = flip_by_game[e["sheet"]]
if (np.abs((fl - np.datetime64(t0)) / np.timedelta64(1, "D")) <= gap).sum() > 1:
continue
cand = []
for s, r in games.items():
f = flip_by_game.get(s, np.array([], dtype="datetime64[ns]"))
clean = not (np.abs((f - np.datetime64(t0)) / np.timedelta64(1, "D")) <= gap).any()
if s == e["sheet"] or clean:
cand.append(s)
ctrl = [s for s in cand if s != e["sheet"]]
ctrl = list(rng.choice(ctrl, min(ncontrol, len(ctrl)), replace=False))
for s in [e["sheet"]] + ctrl:
r = games[s]
base = r.loc[t0 - pd.Timedelta(days=120): t0 - pd.Timedelta(days=31)]
win = r.loc[t0 - pd.Timedelta(days=pre): t0 + pd.Timedelta(days=post - 1)]
if len(base) < 60 or len(win) < pre + post or base.mean() < 0.2:
continue
w = pd.DataFrame({"date": win.index, "ly": np.log1p(win.values / base.mean())})
w["rel"] = (w["date"] - t0).dt.days
w["wk"] = w["rel"] // 7
w["treated"] = int(s == e["sheet"])
w["sheet"], w["stack"], w["dir"] = s, k, np.sign(e["dL"])
out.append(w)
S = pd.concat(out, ignore_index=True)
S["gs"] = S["stack"].astype(str) + "_" + S["sheet"]
S["ds"] = S["stack"].astype(str) + "_" + S["date"].dt.strftime("%Y%m%d")
return S
def event_study(S, direction):
d = S[S["dir"] == direction].copy()
d["post"] = (d["rel"] >= 0).astype(int)
m_avg = pf.feols("ly ~ treated:post | gs + ds", data=d, vcov={"CRV1": "sheet"})
m_es = pf.feols("ly ~ i(wk, treated, ref=-1) | gs + ds", data=d, vcov={"CRV1": "sheet"})
return m_avg, m_es
if __name__ == "__main__":
import warnings
warnings.filterwarnings("ignore", category=UserWarning, module="pyfixest")
df = add_label(build(add_groups(load(DATA_GLOB))))
full = add_label(build(add_groups(load(DATA_GLOB)))) # build with no dropna
S = stack(full)
df = full.dropna(subset=["S_lag", "N_lag", "ly"]) # RD only
for direction in (1, -1):
m_avg, m_es = event_study(S, direction)
print("UP" if direction == 1 else "DOWN", m_avg.coef().iloc[0], m_avg.se().iloc[0])
m_es.iplot() if False else print(m_es.tidy()[["Estimate", "Std. Error"]])
pd.set_option("display.float_format", lambda x: f"{x:.4f}")
pd.set_option("display.width", 220)
for w in (0.01, 0.02, 0.03):
m = rd(df2, THRESH, w)
print(w, m.coef()["above"], m.se()["above"], m.pvalue()["above"])
results = []