unsprawl.reporter¶
Reporting module for filtering and presenting valuation results.
This module handles filtering, ranking, and formatting of valuation results for display and export.
Classes¶
Filter, rank, and render a clean buy list table to console. |
Module Contents¶
- class ReportGenerator(schema=None)[source]¶
Filter, rank, and render a clean buy list table to console.
Filtering¶
Optional exact/partial town filter.
Optional budget filter for maximum resale price.
Extended filters: flat_model, flat_type (exact or partial), storey_min/max, area_min/max, lease_min/max.
Ranking¶
Sort by valuation_score descending (highest implies most undervalued), with ties broken by lowest price_efficiency and then lowest resale_price.
Display the top N results (default: 10).
Rendering¶
Human-friendly table using pandas’ built-in formatting.
- schema¶
- logger¶
- static _parse_storey_range(sr)[source]¶
Parse HDB storey range strings like “07 TO 09” into (min, max).
Non-parsable inputs return (None, None).
- _apply_filters(df, town=None, town_like=None, budget=None, flat_type=None, flat_type_like=None, flat_model=None, flat_model_like=None, storey_min=None, storey_max=None, area_min=None, area_max=None, lease_min=None, lease_max=None)[source]¶
Apply user-specified filters to DataFrame.
- Parameters:
df (pd.DataFrame) – The scored dataset.
town (Optional[str]) – Town name for exact case-insensitive filtering.
town_like (Optional[str]) – Substring case-insensitive match for town.
budget (Optional[float]) – Maximum resale price.
flat_type (Optional[str]) – Exact match filter for flat_type (case-insensitive).
flat_type_like (Optional[str]) – Substring match for flat_type.
flat_model (Optional[str]) – Exact match filter for flat_model.
flat_model_like (Optional[str]) – Substring match for flat_model.
storey_min, storey_max (Optional[int]) – Min/max storey number filter (overlap with storey_range).
area_min, area_max (Optional[float]) – Floor area filters.
lease_min, lease_max (Optional[float]) – Remaining lease (years) filters.
- generate_dataframe(df, town=None, town_like=None, budget=None, flat_type=None, flat_type_like=None, flat_model=None, flat_model_like=None, storey_min=None, storey_max=None, area_min=None, area_max=None, lease_min=None, lease_max=None, top_n=10, full=False)[source]¶
Produce the filtered, sorted DataFrame for display/export.
If full is True, returns all rows after sorting; otherwise, returns the top_n rows.
- render(df, town=None, town_like=None, budget=None, flat_type=None, flat_type_like=None, flat_model=None, flat_model_like=None, storey_min=None, storey_max=None, area_min=None, area_max=None, lease_min=None, lease_max=None, top_n=10)[source]¶
Generate the formatted table for the buy list.
The table prioritizes the most undervalued units by sorting on valuation_score desc, breaking ties by price_efficiency asc and resale_price asc.