A room identifier is an important grouping key when measuring architectural preservation. Across 119 observations from 12 tools, each room has 12 observations except room 08, which has 11. Lower drift indicates closer preservation, but an explicitly failed alignment means the reported measurement is raw.
The program below uses only csv and statistics. Its embedded text contains all 119 observations for the three required columns, taken from the StagingBench data. It first prints room summaries, then recomputes medians using only confirmed alignment successes. Both outputs retain room identifier order.
Empty alignment fields become None, separate from False. This matters for room 01: eight statuses are missing, four are True, and none is explicitly False. Unexpected nonempty alignment labels raise an error instead of silently becoming successes.
import csv
from statistics import median
DATA="""room,architecture_drift,alignment_ok
01,16.2,
02,32.9,False
03,9.2,True
04,40.1,False
05,13.7,True
06,43.4,False
07,41.0,True
08,11.6,True
09,13.1,False
10,22.7,True
01,11.0,
02,24.1,True
03,21.7,True
04,56.5,False
05,21.4,True
06,26.2,True
07,35.1,False
08,17.4,True
09,9.2,False
10,28.0,False
01,28.2,
02,30.6,True
03,29.7,True
04,29.0,False
05,15.5,True
06,21.1,True
07,18.0,True
08,12.6,True
09,14.9,False
10,20.2,True
01,27.1,
02,26.6,True
03,33.5,True
04,28.8,False
05,22.5,True
06,21.3,True
07,24.4,True
08,23.5,True
09,26.9,False
10,26.6,True
01,29.4,
02,6.1,True
03,23.6,True
04,61.5,False
05,36.2,True
06,57.3,False
07,30.4,True
08,22.0,True
09,11.4,False
10,19.9,True
01,18.1,
02,23.3,True
03,21.0,True
04,33.3,True
05,14.8,True
06,22.5,True
07,35.2,True
08,27.4,True
09,10.2,False
10,21.2,True
01,25.4,True
02,33.6,True
03,22.9,True
04,50.4,False
05,38.0,True
06,34.9,True
07,46.3,True
08,38.7,True
09,20.4,False
10,28.2,True
01,11.4,
02,31.3,True
03,26.3,True
04,15.1,True
05,34.9,True
06,16.6,True
07,23.5,True
08,9.7,True
09,5.7,False
10,24.5,True
01,13.3,True
02,11.6,True
03,26.4,True
04,10.4,False
05,19.8,True
06,26.0,True
07,18.9,True
08,7.8,True
09,23.3,False
10,21.0,True
01,10.6,True
02,27.8,True
03,7.5,True
04,6.4,True
05,7.8,True
06,13.7,True
07,9.7,True
08,8.9,True
09,3.1,False
10,17.0,True
01,52.8,True
02,27.1,True
03,61.3,False
04,54.5,False
05,7.2,True
06,9.7,True
07,9.2,True
08,35.5,True
09,7.7,False
10,26.6,True
01,18.9,
02,25.4,True
03,19.1,True
04,15.2,True
05,8.0,True
06,16.3,True
07,42.1,True
09,11.8,False
10,15.7,True
"""
def flag(value):
value=(value or "").strip().lower()
return {"true":True,"false":False,"":None}[value]
def number(value):
return float(value) if value and value.strip() else None
def fmt(value):
return "n/a" if value is None else f"{value:.2f}"
rooms={}
for row in csv.DictReader(DATA.splitlines()):
rooms.setdefault(row["room"],[]).append(
(number(row.get("architecture_drift")),flag(row.get("alignment_ok")))
)
print("room,n,median,min,max,failures,unknown")
for room,records in sorted(rooms.items()):
vals=[d for d,ok in records if d is not None]
stats=[median(vals),min(vals),max(vals)] if vals else [None]*3
failures=sum(ok is False for d,ok in records)
unknown=sum(ok is None for d,ok in records)
print(",".join([room,str(len(records)),*map(fmt,stats),str(failures),str(unknown)]))
print("room,aligned_n,aligned_median")
for room,records in sorted(rooms.items()):
vals=[d for d,ok in records if ok is True and d is not None]
value=median(vals) if vals else None
print(",".join([room,str(len(vals)),fmt(value)]))
Expected output:
room,n,median,min,max,failures,unknown
01,12,18.50,10.60,52.80,0,8
02,12,26.85,6.10,33.60,1,0
03,12,23.25,7.50,61.30,1,0
04,12,31.15,6.40,61.50,8,0
05,12,17.65,7.20,38.00,0,0
06,12,21.90,9.70,57.30,2,0
07,12,27.40,9.20,46.30,1,0
08,11,17.40,7.80,38.70,0,0
09,12,11.60,3.10,26.90,12,0
10,12,21.95,15.70,28.20,1,0
room,aligned_n,aligned_median
01,4,19.35
02,11,26.60
03,11,22.90
04,4,15.15
05,12,17.65
06,10,21.20
07,11,24.40
08,11,17.40
09,0,n/a
10,11,21.20
The second calculation changes several relative comparisons. Room 04 moves from 31.15 across 12 observations to 15.15 across four aligned observations, placing its median below room 08's 17.40 across 11. Room 02 initially has a smaller median than room 07, at 26.85 versus 27.40. Among their 11 aligned observations each, that relationship reverses: 26.60 versus 24.40.
Room 09 illustrates why the empty collection guard matters. All 12 observations failed alignment. Its overall median of 11.60 summarizes raw measurements; its aligned median is unavailable. Printing n/a preserves that distinction without crashing or substituting zero.
Rooms 06 and 10 both display aligned medians of 21.20, based on 10 and 11 observations respectively. Formatting to two decimal places also avoids presenting floating point representation noise as a meaningful difference.
Missing drift values are excluded from numeric calculations, while n counts records. None are missing here. If an entire group lacked numeric values, its median, minimum, and maximum would print n/a.
For interpreting these calculations, consult the StagingBench methodology. Filtering changes which observations contribute. It neither repairs failed alignment nor explains why a room produced its measured values. Keeping sample sizes beside both medians makes that change visible.
Top comments (0)