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
- 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
- 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
- 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:
- 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)
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
- name = 'multicolumn'¶
pyexlatex.table.models.labels.row module¶
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¶
- 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:
- 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:
- property rows¶