pyexlatex.table.models.labels package

Submodules

pyexlatex.table.models.labels.collection module

class pyexlatex.table.models.labels.collection.LabelCollection(values, underline=None)[source]

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

Represents one row of labels. Use to construct a LabelTable to apply to a DataTable.

Main usage is LabelCollection.from_str_list

__init__(values, underline=None)[source]
Parameters
  • values (List[Label]) –

  • underline (Union[int, str, None]) – int, str, or None, pass index or label to underline, pass a str range, e.g. ‘2-5’ for a range of labels to underline, pass space separated indices as a str, e.g. ‘0 2’ for separated underlines, or a combination, e.g. ‘2-5 8’

classmethod from_str_list(str_list, underline=None)[source]
Args:

str_list: underline: int, str, or None, pass index or label to underline, pass a str range, e.g. ‘2-5’ for a

range of labels to underline, pass space separated indices as a str, e.g. ‘0 2’ for separated underlines, or a combination, e.g. ‘2-5 8’

Returns:

Return type

LabelCollection

is_subset_of(other)[source]

Checks whether this label collection is part of another label collection. E.g. if other has [‘a’, ‘b’] and this has [‘a’] then this is a subset.

Return type

bool

matches(other)[source]

Compare on the basis of having same values, rather than same instance Use regular equality to test if same instance :param _sphinx_paramlinks_pyexlatex.table.models.labels.collection.LabelCollection.matches.other: :return:

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.labels.collection.LabelCollection.pad.length: int :param _sphinx_paramlinks_pyexlatex.table.models.labels.collection.LabelCollection.pad.length: :return:

classmethod parse_unknown_type(unknown_type)[source]
Return type

LabelCollection

pop_left()[source]
Return type

Label

repr_cols: List[str] = ['values', 'underlines']
shift_underlines(shift)[source]
values: Sequence

pyexlatex.table.models.labels.label module

class pyexlatex.table.models.labels.label.Label(value, span=1, align='c')[source]

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

Only necessary to use if need to set span or alignment manually. Can construct LabelCollection objects from Labels.

Useful for constructing custom multicolumn labels.

>>>import pyexlatex.table as lt >>>data_table = lt.DataTable.from_df(some_df) >>>label = lt.Label(‘Long label’, span=5, align=’r’) >>>long_label_collection = lt.LabelCollection([label], underline=’1-5’) >>> >>>data_table.column_labels.insert(long_label_collection, 0)

__init__(value, span=1, align='c')[source]
repr_cols: List[str] = ['value', 'span']

pyexlatex.table.models.labels.multicolumnlabel module

class pyexlatex.table.models.labels.multicolumnlabel.MultiColumnLabel(contents, span, align='c', add_table_line_break=True)[source]

Bases: pyexlatex.models.item.MultiOptionSimpleItem

A label which spans multiple columns in a table

__init__(contents, span, align='c', add_table_line_break=True)[source]
name = 'multicolumn'

pyexlatex.table.models.labels.row module

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

Bases: pyexlatex.table.models.table.row.Row

__init__(values)[source]
property length
repr_cols: List[str] = ['values', 'length']
values: Sequence

pyexlatex.table.models.labels.table module

class pyexlatex.table.models.labels.table.LabelTable(label_collections, break_size_adjustment=None)[source]

Bases: pyexlatex.table.models.table.section.TableSection, mixins.repr.ReprMixin

A set of label rows to apply to a DataTable.

Example:

>>>import pyexlatex.table as lt >>>data_table = lt.DataTable.from_df(some_df) >>>col_label_table = lt.LabelTable.from_list_of_lists([[‘One header’],[‘More’,’Headers’]]) >>>row_label_table = lt.LabelTable.from_list_of_lists([[‘Some’,’Row’,’Labels’]]).T >>>data_table.column_labels = col_label_table

property T
__init__(label_collections, break_size_adjustment=None)[source]
append(item)[source]
begins_with(item)[source]
contains(item)[source]

Note: use to compare strings inside LabelCollections. Use label_collection in LabelTable to compare objects :param _sphinx_paramlinks_pyexlatex.table.models.labels.table.LabelTable.contains.item: :return:

classmethod from_df_index(df_columns)[source]
classmethod from_list_of_lists(list_of_lists)[source]
insert(item, index)[source]
property is_empty
property label_collections
property length
matches(other)[source]

Note: use to compare strings inside LabelTables. Use regular equality comparison to compare objects :param _sphinx_paramlinks_pyexlatex.table.models.labels.table.LabelTable.matches.other: :return:

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.labels.table.LabelTable.pad.length: int :param _sphinx_paramlinks_pyexlatex.table.models.labels.table.LabelTable.pad.length: :param _sphinx_paramlinks_pyexlatex.table.models.labels.table.LabelTable.pad.direction: :return:

remove(item)[source]
repr_cols: List[str] = ['label_collections']
property rows
split_bottom_left()[source]

Takes the bottom left label and creates a new LabelTable from it, removing it from this LabelTable

Return type

LabelTable