pyexlatex.table.models.table package¶
Submodules¶
pyexlatex.table.models.table.row module¶
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
- 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:
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 Panelscaption¶ (
Optional
[str
]) – overall caption to place at top of tablealign¶ (
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 textshort_caption¶ (
Optional
[str
]) – Caption that will be used if table name is listed in TOCposition_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 DataFramepanel_names¶ (
Optional
[List
[str
]]) – list of panel names. Must be of same length as outer list in df_list_of_listsshape¶ (
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_listinclude_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 DataFramestop_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_columns¶ (
int
) – vertical spacing to put between TableSectionscaption¶ (
Optional
[str
]) – overall caption to place at top of tablealign¶ (
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 textdata_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 TOCposition_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
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 DataFramesenforce_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_columns¶ (
int
) – vertical spacing to put between TableSectionscaption¶ (
Optional
[str
]) – overall caption to place at top of tablealign¶ (
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 textshort_caption¶ (
Optional
[str
]) – Caption that will be used if table name is listed in TOCposition_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 DataFramestop_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.
caption¶ (
Optional
[str
]) – overall caption to place at top of tablealign¶ (
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 textdata_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 TOCposition_str¶ (
Optional
[str
]) – float positioning str, can include h, t, b, p, !, and H, e.g. htb! or H
- Returns