pyexlatex.table.models.table package

Submodules

pyexlatex.table.models.table.row module

class pyexlatex.table.models.table.row.Row(values)[source]

Bases: pyexlatex.table.models.table.rowbase.RowBase

__init__(values)[source]
property cell_width
classmethod from_latex_row_str(latex_row_str)[source]
repr_cols: List[str] = ['values']
values: Sequence

pyexlatex.table.models.table.rowbase module

class pyexlatex.table.models.table.rowbase.RowBase[source]

Bases: mixins.repr.ReprMixin, pyexlatex.table.models.mixins.addvalues.row.RowAddMixin

property is_spacer
pad(length, direction='right')[source]

Expand row out to the right or left with blanks, until it is length passed :type _sphinx_paramlinks_pyexlatex.table.models.table.rowbase.RowBase.pad.length: int :param _sphinx_paramlinks_pyexlatex.table.models.table.rowbase.RowBase.pad.length: :return:

values: Sequence

pyexlatex.table.models.table.section module

class pyexlatex.table.models.table.section.TableSection(rows, break_size_adjustment=None)[source]

Bases: mixins.repr.ReprMixin

__init__(rows, break_size_adjustment=None)[source]
property cell_width
property is_spacer
join(sections)[source]

Repliactes str.join behavior. Useful for creating padding spaces in a PanelGrid/PanelCollection :param _sphinx_paramlinks_pyexlatex.table.models.table.section.TableSection.join.sections: :return:

property length
property num_columns
pad(length, direction='right')[source]

Expand table out to the right or left with blanks, until it is length passed (apply to every row) :type _sphinx_paramlinks_pyexlatex.table.models.table.section.TableSection.pad.length: int :param _sphinx_paramlinks_pyexlatex.table.models.table.section.TableSection.pad.length: :param _sphinx_paramlinks_pyexlatex.table.models.table.section.TableSection.pad.direction: :return:

repr_cols: List[str] = ['rows']

pyexlatex.table.models.table.table module

class pyexlatex.table.models.table.table.Table(panels, caption=None, above_text=None, below_text=None, align=None, mid_rules=True, landscape=False, label=None, short_caption=None, position_str=None)[source]

Bases: pyexlatex.models.documentitem.DocumentItem, mixins.repr.ReprMixin

An object for creating latex tables. Easiest way to create is with Table.from_list_of_lists_of_dfs, but for more control, construct Panel objects and use Table.from_panel_list

__init__(panels, caption=None, above_text=None, below_text=None, align=None, mid_rules=True, landscape=False, label=None, short_caption=None, position_str=None)[source]
Parameters
  • panels (PanelCollection) – list of Panels

  • caption (Optional[str]) – overall caption to place at top of table

  • above_text (Optional[str]) – Not yet implemented

  • below_text (Optional[str]) – text to place below table

  • align (Optional[str]) – Can take any string that would normally used in tabular (i.e. rrr for three columns right aligned) as well as ., S, d{decimal format}, and D{in sep}{out sep}{decimal format} for decimal aligned, and L{<width>), C{<width>}, and R{<width>} (i.e. L{3cm}) for left, center, and right aligned fixed width, and s for units. @{} or !{} with optional contents inside the braces can be passed to control the beginning and end of each cell ., d, and D use the dcolumn package while S uses the siunitx package and they have slightly different behavior. . and d are custom columns created to simplify using D: . is decimal aligned with any number of decimal places, d allows specifying the number of decimals, but both use . as the input and output separator. Default is first column left aligned, rest center aligned.

  • mid_rules – whether to add mid rules between panels

  • landscape – whether to output landscape tex

  • label (Optional[str]) – label for table to be referenced in text

  • short_caption (Optional[str]) – Caption that will be used if table name is listed in TOC

  • position_str (Optional[str]) – float positioning str, can include h, t, b, p, !, and H, e.g. htb! or H

property align
classmethod from_list_of_lists_of_dfs(df_list_of_lists, panel_names=None, shape=None, include_columns=True, include_index=False, label_consolidation='str', enforce_label_order=True, top_left_corner_labels=None, pad_rows=1, pad_columns=1, caption=None, above_text=None, below_text=None, align=None, mid_rules=True, landscape=False, label=None, data_table_kwargs={}, short_caption=None, position_str=None)[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 or sub panels individually with DataTable.from_df then make modifications

Parameters
  • df_list_of_lists (List[List[DataFrame]]) – list of lists of pandas DataFrame

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

  • 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. Note: this is for each panel. To apply a different shape to each Panel, construct Panels individually and pass to Table.from_panel_list

  • include_columns

  • include_index

  • label_consolidation (str) – pass ‘object’ to to avoid consolidating labels. pass ‘str’ to consolidate if column or index contents are identical within a column or row of DataFrames

  • 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.

  • 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.

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

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

  • caption (Optional[str]) – overall caption to place at top of table

  • above_text (Optional[str]) – Not yet implemented

  • below_text (Optional[str]) – text to place below table

  • align (Optional[str]) – Can take any string that would normally used in tabular (i.e. rrr for three columns right aligned) as well as ., S, d{decimal format}, and D{in sep}{out sep}{decimal format} for decimal aligned, and L{<width>), C{<width>}, and R{<width>} (i.e. L{3cm}) for left, center, and right aligned fixed width, and s for units. @{} or !{} with optional contents inside the braces can be passed to control the beginning and end of each cell ., d, and D use the dcolumn package while S uses the siunitx package and they have slightly different behavior. . and d are custom columns created to simplify using D: . is decimal aligned with any number of decimal places, d allows specifying the number of decimals, but both use . as the input and output separator. Default is first column left aligned, rest center aligned.

  • mid_rules – whether to add mid rules between panels

  • landscape – whether to output landscape tex

  • label (Optional[str]) – label for table to be referenced in text

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

  • short_caption (Optional[str]) – Caption that will be used if table name is listed in TOC

  • position_str (Optional[str]) – float positioning str, can include h, t, b, p, !, and H, e.g. htb! or H

Returns

classmethod from_panel_list(panels, label_consolidation='object', enforce_label_order=True, top_left_corner_labels=None, pad_rows=1, pad_columns=1, caption=None, above_text=None, below_text=None, align=None, mid_rules=True, landscape=False, label=None, short_caption=None, position_str=None)[source]

Note: to quickly create latex tables, use Table.from_list_of_lists_of_dfs to pass pandas DataFrames directly. Use this method when more control is needed than is provided by that method. Construct Panels individually, either directly from DataFrames with Panel.from_df_list, or for even more control, use DataTable.from_df and override labels with custom LabelTables.

Parameters
  • panels (List[Panel]) – list of Panels

  • label_consolidation (str) – pass ‘object’ to to avoid consolidating labels. pass ‘str’ to consolidate if column or index contents are identical within a column or row of DataFrames

  • 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

  • caption (Optional[str]) – overall caption to place at top of table

  • above_text (Optional[str]) – Not yet implemented

  • below_text (Optional[str]) – text to place below table

  • align (Optional[str]) – Can take any string that would normally used in tabular (i.e. rrr for three columns right aligned) as well as ., S, d{decimal format}, and D{in sep}{out sep}{decimal format} for decimal aligned, and L{<width>), C{<width>}, and R{<width>} (i.e. L{3cm}) for left, center, and right aligned fixed width, and s for units. @{} or !{} with optional contents inside the braces can be passed to control the beginning and end of each cell ., d, and D use the dcolumn package while S uses the siunitx package and they have slightly different behavior. . and d are custom columns created to simplify using D: . is decimal aligned with any number of decimal places, d allows specifying the number of decimals, but both use . as the input and output separator. Default is first column left aligned, rest center aligned.

  • mid_rules – whether to add mid rules between panels

  • landscape – whether to output landscape tex

  • label (Optional[str]) – label for table to be referenced in text

  • short_caption (Optional[str]) – Caption that will be used if table name is listed in TOC

  • position_str (Optional[str]) – float positioning str, can include h, t, b, p, !, and H, e.g. htb! or H

Returns

classmethod from_panel_name_df_dict(panel_name_df_dict, include_columns=True, include_index=False, label_consolidation='str', enforce_label_order=True, top_left_corner_labels=None, pad_rows=1, caption=None, above_text=None, below_text=None, align=None, mid_rules=True, landscape=False, label=None, data_table_kwargs={}, short_caption=None, position_str=None)[source]

Convenience method for when there is only one DataFrame per panel. All options will be applied all panels and DataTables. To apply different options to each panel, construct them individually using Panel.from_df_list or sub panels individually with DataTable.from_df then make modifications

Parameters
  • panel_name_df_dict (Dict[str, DataFrame]) – dictionary where keys are names of panels, and values are DataFrames to put in panels (only one DataFrame per panel. Use another method if more control is needed)

  • include_columns

  • include_index

  • label_consolidation (str) – pass ‘object’ to to avoid consolidating labels. pass ‘str’ to consolidate if column or index contents are identical within a column or row of DataFrames

  • 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.

  • 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.

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

  • caption (Optional[str]) – overall caption to place at top of table

  • above_text (Optional[str]) – Not yet implemented

  • below_text (Optional[str]) – text to place below table

  • align (Optional[str]) – Can take any string that would normally used in tabular (i.e. rrr for three columns right aligned) as well as ., S, d{decimal format}, and D{in sep}{out sep}{decimal format} for decimal aligned, and L{<width>), C{<width>}, and R{<width>} (i.e. L{3cm}) for left, center, and right aligned fixed width, and s for units. @{} or !{} with optional contents inside the braces can be passed to control the beginning and end of each cell ., d, and D use the dcolumn package while S uses the siunitx package and they have slightly different behavior. . and d are custom columns created to simplify using D: . is decimal aligned with any number of decimal places, d allows specifying the number of decimals, but both use . as the input and output separator. Default is first column left aligned, rest center aligned.

  • mid_rules – whether to add mid rules between panels

  • landscape – whether to output landscape tex

  • label (Optional[str]) – label for table to be referenced in text

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

  • short_caption (Optional[str]) – Caption that will be used if table name is listed in TOC

  • position_str (Optional[str]) – float positioning str, can include h, t, b, p, !, and H, e.g. htb! or H

Returns

repr_cols: List[str] = ['caption', 'above_text', 'panels', 'below_text']
set_begin_document_items(landscape)[source]
tex_obj(as_document=True, as_single_tabular=False, as_panel_tabular_list=False)[source]
to_pdf_and_move(outfolder, outname=None, move_folder_name='Tables', as_document=True)[source]
to_tex(as_document=True)[source]