reportcompiler_ic_tools.tables

This module contains helper functions to create tables with the Information Centre data.

Functions

reportcompiler_ic_tools.tables.generate_table_data(data_dict, selected_columns=None, column_names=None, row_id_column=None, format='latex', collapse_refs=True, footer=None, markers=None)
Generates a new dataframe with the markers corresponding to the defined
references (sources, notes, …), alongside a list of the markers’ meaning.
Parameters:
  • data_dict (dict) – Dictionary returned by the IC data fetcher
  • selected_columns (list) – List with the column names to be selected from the original dataframe
  • column_names (list) – List with the column names of the selected dataframe columns
  • row_id_column (str) – Column name that will contain the marks for row references
  • format (str) – Format that the returned dataframe should comply with
  • collapse_refs (bool) – Whether markers should be collapsed when appropriate (e.g. all cells of a column to the column header)
  • footer (dict) – Dictionary with the footer information as returned from previous calls to this same function. This allows chaining several data sources in one single footer.
  • markers (dict) – Dictionary with generators for markers for each type of reference (‘sources’, ‘notes’, ‘methods’, ‘years’). If None, new generators will be initialized (starting at 1 with sources, ‘a’ with notes, …).
Returns:

Dictionary with four components: table, columns, footer, markers; where table is the original dataframe with the necessary reference markers, columns is the list with the table columns as will be displayed, footer is a nested structure: for each type (sources, notes, …) there is a list of dictionaries with each (‘marker’ key) and associated reference (‘text’ key) and markers is a dictionary with the generators for the markers of each reference type.

Return type:

dict