compass.utilities.finalize.doc_infos_to_db#

doc_infos_to_db(doc_infos, output_columns)[source]#

Aggregate parsed ordinance CSV files into a normalized database

Parameters:
  • doc_infos (Iterable) – Iterable of dictionaries describing ordinance extraction results. Each dictionary must contain "ord_db_fp" (path to a parsed CSV), "source" (document URL), "date" (tuple of year, month, day, with None allowed), and "jurisdiction" (a Jurisdiction instance).

  • output_columns (list) – List of expected output columns (as compass.plugin.interface.OutputColumn instances) for the consolidated database. The function enforces the presence of these columns in the output pandas.DataFrame, filling in missing columns with null values as needed.

Returns:

  • pandas.DataFrame – Consolidated ordinance dataset.

  • int – Number of jurisdictions contributing at least one ordinance to the consolidated dataset.

Notes

Empty or None entries in doc_infos are skipped. Ordinance CSVs that lack parsed values (num_ordinances_dataframe equals zero) are ignored. The returned DataFrame enforces an ordered column layout and casts the quantitative flag to nullable boolean.