#!/usr/bin/env python3 """Reproduce the published filter counts from the downloaded UTF-8 CSV.""" import csv from decimal import Decimal import json import sys def check(path): with open(path, encoding='utf-8-sig', newline='') as source: rows = [r for r in csv.DictReader(source) if r['집계포함'] == '포함' and r['단지명'] == '인왕산아이파크'] area = lambda r: Decimal('80') <= Decimal(r['전용면적(㎡)']) <= Decimal('85') cases = [rows, [r for r in rows if area(r)], [r for r in rows if area(r) and r['계약월'] == '202609'], [r for r in rows if r['계약월'] == '202609']] return [{'count': len(group), 'mean_amount_manwon': str(sum(Decimal(r['금액(만원)']) for r in group) / len(group)) if group else None} for group in cases] if __name__ == '__main__': if len(sys.argv) != 2: raise SystemExit('Usage: python3 check-small-sample-filters.py transactions.csv') print(json.dumps(check(sys.argv[1]), ensure_ascii=False, indent=2))