CaMa development record: tables carry their column order

This commit is contained in:
rockdrigo
2026-11-21 05:03:52 -06:00
parent f3be09467f
commit 4c8b559557
2 changed files with 5 additions and 2 deletions
+3 -2
View File
@@ -72,12 +72,13 @@ def _seer_settings(development: dict):
balancing=dataclasses.replace(s.balancing, exclude_censored_years=False))
def _records(path: Path) -> list[dict]:
def _records(path: Path) -> dict:
"""The table as `{"columnas": [...], "filas": [...]}`: the columns in the file's order, which JSON objects do not keep."""
table = pd.read_csv(path)
if table.columns[0].startswith("Unnamed"):
table = table.rename(columns={table.columns[0]: "indice"})
table = table.head(MAX_ROWS).replace([np.inf, -np.inf], np.nan).astype(object)
return table.where(table.notna(), None).to_dict("records")
return {"columnas": [str(c) for c in table.columns], "filas": table.where(table.notna(), None).to_dict("records")}
def development(labelled_members: pd.DataFrame, desarrollo: dict) -> dict:
+2
View File
@@ -332,4 +332,6 @@ def test_the_development_stages_publish_their_tables_and_figures_on_a_varied_coh
assert r["errores"] == {}, r["errores"]
assert {"or_lr_balanceada", "hbn_arcos", "subgrupos_weibull", "prueba_edad"} <= set(r["tablas"])
arcs = r["tablas"]["hbn_arcos"]
assert arcs["columnas"] == list(arcs["filas"][0]) and len(arcs["columnas"]) > 1
assert r["figuras"] and all(isinstance(v, str) for v in r["figuras"].values())