MCPcopy Index your code
hub / github.com/astanin/python-tabulate / tabulate

Function tabulate

tabulate/__init__.py:1746–2521  ·  view source on GitHub ↗

Format a fixed width table for pretty printing. >>> print(tabulate([[1, 2.34], [-56, "8.999"], ["2", "10001"]])) --- --------- 1 2.34 -56 8.999 2 10001 --- --------- The first required argument (`tabular_data`) can be a list-of-lists (or another ite

(
    tabular_data,
    headers=(),
    tablefmt="simple",
    floatfmt=_DEFAULT_FLOATFMT,
    intfmt=_DEFAULT_INTFMT,
    numalign=_DEFAULT_ALIGN,
    stralign=_DEFAULT_ALIGN,
    missingval=_DEFAULT_MISSINGVAL,
    showindex="default",
    disable_numparse=False,
    colglobalalign=None,
    colalign=None,
    preserve_whitespace=False,
    maxcolwidths=None,
    headersglobalalign=None,
    headersalign=None,
    rowalign=None,
    maxheadercolwidths=None,
    break_long_words=_BREAK_LONG_WORDS,
    break_on_hyphens=_BREAK_ON_HYPHENS,
)

Source from the content-addressed store, hash-verified

1744
1745
1746def tabulate(
1747 tabular_data,
1748 headers=(),
1749 tablefmt="simple",
1750 floatfmt=_DEFAULT_FLOATFMT,
1751 intfmt=_DEFAULT_INTFMT,
1752 numalign=_DEFAULT_ALIGN,
1753 stralign=_DEFAULT_ALIGN,
1754 missingval=_DEFAULT_MISSINGVAL,
1755 showindex="default",
1756 disable_numparse=False,
1757 colglobalalign=None,
1758 colalign=None,
1759 preserve_whitespace=False,
1760 maxcolwidths=None,
1761 headersglobalalign=None,
1762 headersalign=None,
1763 rowalign=None,
1764 maxheadercolwidths=None,
1765 break_long_words=_BREAK_LONG_WORDS,
1766 break_on_hyphens=_BREAK_ON_HYPHENS,
1767):
1768 """Format a fixed width table for pretty printing.
1769
1770 >>> print(tabulate([[1, 2.34], [-56, "8.999"], ["2", "10001"]]))
1771 --- ---------
1772 1 2.34
1773 -56 8.999
1774 2 10001
1775 --- ---------
1776
1777 The first required argument (`tabular_data`) can be a
1778 list-of-lists (or another iterable of iterables), a list of named
1779 tuples, a dictionary of iterables, an iterable of dictionaries,
1780 an iterable of dataclasses, a two-dimensional NumPy array,
1781 NumPy record array, or a Pandas' dataframe.
1782
1783
1784 Table headers
1785 -------------
1786
1787 To print nice column headers, supply the second argument (`headers`):
1788
1789 - `headers` can be an explicit list of column headers
1790 - if `headers="firstrow"`, then the first row of data is used
1791 - if `headers="keys"`, then dictionary keys or column indices are used
1792
1793 Otherwise a headerless table is produced.
1794
1795 If the number of headers is less than the number of columns, they
1796 are supposed to be names of the last columns. This is consistent
1797 with the plain-text format of R and Pandas' dataframes.
1798
1799 >>> print(tabulate([["sex","age"],["Alice","F",24],["Bob","M",19]],
1800 ... headers="firstrow"))
1801 sex age
1802 ----- ----- -----
1803 Alice F 24

Calls 14

_normalize_tabular_dataFunction · 0.85
_remove_separating_linesFunction · 0.85
_expand_iterableFunction · 0.85
_expand_numparseFunction · 0.85
_wrap_text_to_colwidthsFunction · 0.85
_rst_escape_first_columnFunction · 0.85
_is_multilineFunction · 0.85
_choose_width_fnFunction · 0.85
_column_typeFunction · 0.85
_formatFunction · 0.85
_align_columnFunction · 0.85
_align_headerFunction · 0.85