pyexlatex.table.models.panels package

Submodules

pyexlatex.table.models.panels.collection module

class pyexlatex.table.models.panels.collection.PanelCollection(panels, label_consolidation='object', enforce_label_order=True, top_left_corner_labels=None, pad_rows=1, pad_columns=1, name=None)[source]

Bases: mixins.repr.ReprMixin

Lays panel contents in a grid, consolidates labels, creates padding between tables

__init__(panels, label_consolidation='object', enforce_label_order=True, top_left_corner_labels=None, pad_rows=1, pad_columns=1, name=None)[source]
Parameters
  • panels (List[Panel]) – list of Panels, which represent a full set of rows of the table. for multiple sections in one set of rows, create DataTables for each section and pass to Panels.

  • label_consolidation (str) – pass ‘object’ to compare object equality for label consolidation, ‘str’ for converting all labels to strings then comparing equality. Use ‘object’ for more control over consolidation.

  • enforce_label_order – pass False to allow consolidating lower labels even if upper labels do not match. e.g. if labels on one table are [[‘Top1’], [‘Bot1’, ‘Bot2’]], then labels on the other table are [[‘Top2’], [‘Bot1’, ‘Bot2’]], consolidated labels when passing False will be [‘Bot1’, ‘Bot2’], while when passing True, no labels will be consolidated. Under True, will start from the top label, then stop consolidating once it has a mismatch.

  • top_left_corner_labels (Union[LabelTable, LabelCollection, List[AnyStr], AnyStr, None]) – additional labels to place in the top left corner. pass a single string or a list of strings for convenience. a list of strings will be create labels which span the gap horizontally and go downwards, one label per row. pass LabelCollection or LabelTable for more control.

  • pad_rows (int) – horizontal spacing to put between panels

  • pad_columns (int) – vertical spacing to put between TableSections

  • name (Optional[str]) – name that will be used to construct caption in output

consolidate_labels()[source]
classmethod from_list_of_lists_of_dfs(df_list_of_lists, panel_names=None, *args, panel_kwargs={}, data_table_kwargs={}, **kwargs)[source]

To create a single panel table, pass a single list within a list of DataFrames, e.g. [[df1, df2]] then shape will specify how the DataFrames will be organized in the Panel. If you pass two lists within the outer list, then shape will apply to each Panel. So [[df1, df2], [df3, df4]] with shape=(1,2) create a two Panel table with two tables placed within each panel going horizontally, so that the overall shape is (2,2).

Note: convenience method for if not much control over table is needed. To apply different options to each panel, construct them individually using Panel.from_df_list

Parameters
  • df_list_of_lists (List[List[DataFrame]]) –

  • panel_names (Optional[List[str]]) – list of panel names. Must be of same length as outer list in df_list_of_lists

  • args – args to pass to PanelCollection constructor

  • panel_kwargs – Panel.from_df_list kwargs. Same kwargs will be passed to all panels

  • kwargs – kwargs to pass to PanelCollection constructor

  • data_table_kwargs – kwargs to be passed to DataTable.from_df. Same kwargs will be passed to all data tables.

Returns

PanelCollection

property grid
iterpanels(add_panel_order_label=True)[source]

First panel is headers. Then each original panel

self.grid includes all panels as well as labels. Need to separate back out to get each panel

Parameters

add_panel_order_label (bool) – Whether to add to names of panels Panel A:, Panel B:,

and so on

Returns

Return type

property num_columns: int
Return type

int

pad_grid()[source]
repr_cols: List[str] = ['name', 'panels']
property rows
to_tex(mid_rule=True)[source]

pyexlatex.table.models.panels.grid module

class pyexlatex.table.models.panels.grid.GridShape(input_array, info=None)[source]

Bases: numpy.ndarray

property cell_width: int
Return type

int

property cell_widths: List[int]
Return type

List[int]

property data_has_row_labels: bool
Return type

bool

class pyexlatex.table.models.panels.grid.PanelGrid(sections: List[pyexlatex.table.models.table.section.TableSection], shape: Optional[tuple] = None)[source]

Bases: mixins.repr.ReprMixin

repr_cols: List[str] = ['sections', 'shape']
pyexlatex.table.models.panels.grid.index_array(sections, shape=None)[source]

pyexlatex.table.models.panels.panel module

class pyexlatex.table.models.panels.panel.Panel(panel_grid, name=None)[source]

Bases: mixins.repr.ReprMixin

Represents one section of a table. May have multiple DataTables within one panel.

__init__(panel_grid, name=None)[source]
classmethod from_data_tables(data_table_list, shape=None, name=None)[source]
Parameters
  • data_table_list (List[DataTable]) – list of pyexlatex.table.DataTable

  • shape (Optional[tuple]) – tuple of (rows, columns) to arrange DataTables. They will be placed from left to right, then from top to bottom. passsing None defaults one column, as many rows as DataTables

  • name (Optional[str]) – name to be displayed with panel

Returns

classmethod from_df(df, include_columns=True, include_index=False, name=None)[source]
classmethod from_df_list(df_list, shape=None, name=None, include_columns=True, include_index=False, data_table_kwargs={})[source]
Parameters
  • df_list (List[DataFrame]) – list of pandas DataFrame

  • shape (Optional[tuple]) – tuple of (rows, columns) to arrange DataFrames. They will be placed from left to right, then from top to bottom. passsing None defaults one column, as many rows as DataFrames

  • name (Optional[str]) – name to be displayed with panel

  • include_columns

  • include_index

  • data_table_kwargs – kwargs to be passed to DataTable.from_df. Same kwargs will be passed to all data tables.

Returns

property is_spacer
property num_columns
repr_cols: List[str] = ['name', 'panel_grid']
property rows