Spaces:
Running
Running
Chest Pain Claude Sonnet 4.6 commited on
Commit ·
a13be70
1
Parent(s): 92e9edc
v1.95: clean column display names in table headers
Browse filesAdd COL_LABELS mapping + _pretty_col() fallback so all raw API field
names (underscores, trailing underscores, cryptic abbreviations) are
replaced with readable labels in the dataframe header row.
e.g. filing_representative_business_name → Applicant Firm,
owner_s_business_name → Owner Business, job_filing_number → Filing #
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
gui.py
CHANGED
|
@@ -146,6 +146,80 @@ button.primary, .gr-button.primary {{ font-weight: 700; }}
|
|
| 146 |
CUSTOM_CSS = _build_font_css()
|
| 147 |
|
| 148 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 149 |
# ---- helpers ----
|
| 150 |
def _sanitize_visible(visible: list[str], cols: list[str]) -> list[str]:
|
| 151 |
set_cols = set(cols)
|
|
@@ -255,7 +329,7 @@ def create_app():
|
|
| 255 |
source_key_state = gr.State("leads_unpermitted")
|
| 256 |
|
| 257 |
def _display_view(df: pd.DataFrame, vis: list, rows: int):
|
| 258 |
-
"""Slice df to visible cols + rows,
|
| 259 |
view = df[vis].head(int(rows)).copy()
|
| 260 |
datatypes = []
|
| 261 |
for col in vis:
|
|
@@ -266,6 +340,7 @@ def create_app():
|
|
| 266 |
datatypes.append("markdown")
|
| 267 |
else:
|
| 268 |
datatypes.append("str")
|
|
|
|
| 269 |
return gr.update(value=view, datatype=datatypes)
|
| 270 |
|
| 271 |
def _dataset_key_from_label(label: str) -> str:
|
|
|
|
| 146 |
CUSTOM_CSS = _build_font_css()
|
| 147 |
|
| 148 |
|
| 149 |
+
# ---- Column display-name map ----
|
| 150 |
+
COL_LABELS: dict[str, str] = {
|
| 151 |
+
# Address / location
|
| 152 |
+
"full_address": "Address",
|
| 153 |
+
"house_no": "House #",
|
| 154 |
+
"house_number": "House #",
|
| 155 |
+
"street_name": "Street",
|
| 156 |
+
"borough": "Borough",
|
| 157 |
+
"zip": "ZIP",
|
| 158 |
+
"zip_code": "ZIP",
|
| 159 |
+
"postcode": "ZIP",
|
| 160 |
+
"bin": "BIN",
|
| 161 |
+
"bbl": "BBL",
|
| 162 |
+
"block": "Block",
|
| 163 |
+
"lot": "Lot",
|
| 164 |
+
"community_board": "Community Board",
|
| 165 |
+
"commmunity_board": "Community Board",
|
| 166 |
+
"latitude": "Lat",
|
| 167 |
+
"longitude": "Lon",
|
| 168 |
+
# Filing / job
|
| 169 |
+
"filing_date": "Filing Date",
|
| 170 |
+
"filing_status": "Filing Status",
|
| 171 |
+
"job_filing_number": "Filing #",
|
| 172 |
+
"job_type": "Job Type",
|
| 173 |
+
"job_status": "Job Status",
|
| 174 |
+
"job_status_descrp": "Job Status Description",
|
| 175 |
+
"job_description": "Description",
|
| 176 |
+
"permit_type": "Permit Type",
|
| 177 |
+
"initial_cost": "Initial Cost",
|
| 178 |
+
"total_construction_floor_area": "Floor Area",
|
| 179 |
+
"signoff_date": "Sign-off Date",
|
| 180 |
+
"first_permit_date": "First Permit Date",
|
| 181 |
+
# Work type flags
|
| 182 |
+
"general_construction_work_type_": "GC Work Type",
|
| 183 |
+
"plumbing_work_type": "Plumbing",
|
| 184 |
+
"sprinkler_work_type": "Sprinkler",
|
| 185 |
+
"structural_work_type_": "Structural",
|
| 186 |
+
"foundation_work_type_": "Foundation",
|
| 187 |
+
"mechanical_systems_work_type_": "Mechanical",
|
| 188 |
+
"earth_work_work_type_": "Earthwork",
|
| 189 |
+
"boiler_equipment_work_type_": "Boiler/Equip",
|
| 190 |
+
# Applicant / owner
|
| 191 |
+
"filing_representative_business_name": "Applicant Firm",
|
| 192 |
+
"applicant_first_name": "First Name",
|
| 193 |
+
"applicant_last_name": "Last Name",
|
| 194 |
+
"applicant_professional_title": "Title",
|
| 195 |
+
"applicants_middle_initial": "MI",
|
| 196 |
+
"applicant_license": "License #",
|
| 197 |
+
"applicant_search": "Search",
|
| 198 |
+
"owner_s_business_name": "Owner Business",
|
| 199 |
+
"owner_s_street_name": "Owner Street",
|
| 200 |
+
# Stalled
|
| 201 |
+
"days_stalled": "Days Stalled",
|
| 202 |
+
"complaint_date": "Complaint Date",
|
| 203 |
+
"date_complaint_received": "Complaint Received",
|
| 204 |
+
"complaint_number": "Complaint #",
|
| 205 |
+
"dobrundate": "DOB Run Date",
|
| 206 |
+
# Distressed
|
| 207 |
+
"distress_score": "Score",
|
| 208 |
+
"distress_types": "Distress Types",
|
| 209 |
+
"distress_date": "Distress Date",
|
| 210 |
+
"days_since_distress": "Days Since",
|
| 211 |
+
"source": "Source",
|
| 212 |
+
}
|
| 213 |
+
|
| 214 |
+
|
| 215 |
+
def _pretty_col(col: str) -> str:
|
| 216 |
+
"""Return a clean display label for a raw column name."""
|
| 217 |
+
if col in COL_LABELS:
|
| 218 |
+
return COL_LABELS[col]
|
| 219 |
+
# Fallback: strip trailing underscores, replace _ with space, title-case
|
| 220 |
+
return col.strip("_").replace("_", " ").title()
|
| 221 |
+
|
| 222 |
+
|
| 223 |
# ---- helpers ----
|
| 224 |
def _sanitize_visible(visible: list[str], cols: list[str]) -> list[str]:
|
| 225 |
set_cols = set(cols)
|
|
|
|
| 329 |
source_key_state = gr.State("leads_unpermitted")
|
| 330 |
|
| 331 |
def _display_view(df: pd.DataFrame, vis: list, rows: int):
|
| 332 |
+
"""Slice df to visible cols + rows, rename headers, format links."""
|
| 333 |
view = df[vis].head(int(rows)).copy()
|
| 334 |
datatypes = []
|
| 335 |
for col in vis:
|
|
|
|
| 340 |
datatypes.append("markdown")
|
| 341 |
else:
|
| 342 |
datatypes.append("str")
|
| 343 |
+
view.columns = [_pretty_col(c) for c in vis]
|
| 344 |
return gr.update(value=view, datatype=datatypes)
|
| 345 |
|
| 346 |
def _dataset_key_from_label(label: str) -> str:
|