You can combine the usage of zip() with tabulate to create a nicer looking table:

from tabulate import tabulate
headers = ['planet', 'amp', 'mass', 'period', 'ecc']    

amp = [1.1, 1.2, 1.3, 1.4]
mass = [2.1, 2.2, 2.3, 2.4]
period = [3.1, 3.2, 3.3, 3.4]
ecc = [4.1, 4.2, 4.3, 4.4]
planet = range(1, len(amp)+1)

table = zip(planet, amp, mass, period, ecc)
print(tabulate(table, headers=headers, floatfmt=".4f"))

Output:

  planet     amp    mass    period     ecc
--------  ------  ------  --------  ------
       1  1.1000  2.1000    3.1000  4.1000
       2  1.2000  2.2000    3.2000  4.2000
       3  1.3000  2.3000    3.3000  4.3000
       4  1.4000  2.4000    3.4000  4.4000
Answer from Liran Funaro on Stack Overflow
🌐
PyPI
pypi.org › project › tabulate
tabulate · PyPI
In this case the command line utility will be installed to ~/.local/bin/tabulate on Linux and to %APPDATA%\Python\Scripts\tabulate.exe on Windows. To install just the library on Unix-like operating systems: ... The module provides just one function, tabulate, which takes a list of lists or another tabular data type as the first argument, and outputs a nicely formatted plain-text table:
      » pip install tabulate
    
Published   Mar 04, 2026
Version   0.10.0
🌐
Python for Network Engineers
pyneng.readthedocs.io › en › latest › book › 12_useful_modules › tabulate.html
tabulate - Python for network engineers
In [27]: print(tabulate(list_of_dict, headers='keys', tablefmt='pipe', stralign='center')) | Interface | IP | Status | Protocol | |:---------------:|:---------:|:--------:|:----------:| | FastEthernet0/0 | 15.0.15.1 | up | up | | FastEthernet0/1 | 10.0.12.1 | up | up | | FastEthernet0/2 | 10.0.13.1 | up | up | | Loopback0 | 10.1.1.1 | up | up | | Loopback100 | 100.0.0.1 | up | up |
Top answer
1 of 16
1041

There are some light and useful python packages for this purpose:

1. tabulate

https://pypi.python.org/pypi/tabulate

from tabulate import tabulate
print(tabulate([['Alice', 24], ['Bob', 19]], headers=['Name', 'Age']))
Name      Age
------  -----
Alice      24
Bob        19

tabulate has many options to specify headers and table format.

print(tabulate(
    [['Alice', 24], ['Bob', 19]],
    headers=['Name', 'Age'],
    tablefmt='orgtbl'))
| Name   |   Age |
|--------+-------|
| Alice  |    24 |
| Bob    |    19 |

2. PrettyTable

https://pypi.python.org/pypi/PrettyTable

from prettytable import PrettyTable
t = PrettyTable(['Name', 'Age'])
t.add_row(['Alice', 24])
t.add_row(['Bob', 19])
print(t)
+-------+-----+
|  Name | Age |
+-------+-----+
| Alice |  24 |
|  Bob  |  19 |
+-------+-----+

PrettyTable has options to read data from csv, html, sql database. Also you are able to select subset of data, sort table and change table styles.

3. texttable

https://pypi.python.org/pypi/texttable

from texttable import Texttable
t = Texttable()
t.add_rows([['Name', 'Age'], ['Alice', 24], ['Bob', 19]])
print(t.draw())
+-------+-----+
| Name  | Age |
+=======+=====+
| Alice | 24  |
+-------+-----+
| Bob   | 19  |
+-------+-----+

with texttable you can control horizontal/vertical align, border style and data types.

4. termtables

https://github.com/nschloe/termtables

import termtables as tt

string = tt.to_string(
    [["Alice", 24], ["Bob", 19]],
    header=["Name", "Age"],
    style=tt.styles.ascii_thin_double,
    # alignment="ll",
    # padding=(0, 1),
)
print(string)
+-------+-----+
| Name  | Age |
+=======+=====+
| Alice | 24  |
+-------+-----+
| Bob   | 19  |
+-------+-----+

with texttable you can control horizontal/vertical align, border style and data types.

Other options

  • terminaltables - Easily draw tables in terminal/console applications from a list of lists of strings. Supports multi-line rows.
  • asciitable can read and write a wide range of ASCII table formats via built-in Extension Reader Classes.
2 of 16
324

Some ad-hoc code:

row_format ="{:>15}" * (len(teams_list) + 1)
print(row_format.format("", *teams_list))
for team, row in zip(teams_list, data):
    print(row_format.format(team, *row))

This relies on str.format() and the Format Specification Mini-Language.

🌐
GeeksforGeeks
geeksforgeeks.org › python › introduction-to-python-tabulate-library
Introduction to Python Tabulate Library - GeeksforGeeks
July 23, 2025 - The tabulate library is a Python library that provides a function to display data in various tabular formats. It can process data structures such as lists, lists of dictionaries, or pandas DataFrames and output them in formats like plain text, ...
🌐
DataCamp
datacamp.com › tutorial › python-tabulate
Python Tabulate: A Full Guide | DataCamp
September 5, 2024 - The tabulate library supports table ... to create table outputs from the following data structures: List of lists, list of dictionaries, dictionary of iterables, two-dimensional NumPy arrays, and Pandas DataFrames....
🌐
Readthedocs
pyhdust.readthedocs.io › tabulate.html
tabulate: auxiliary module to tablature matrix — Python tools for the BeACoN group Stable documentation
>>> tsv = simple_separated_format("\t") ; tabulate([["foo", 1], ["spam", 23]], tablefmt=tsv) == 'foo \t 1' + '\nspam\t23' True
🌐
Medium
medium.com › @jainsnehasj6 › mastering-tabulate-in-python-create-beautiful-tables-effortlessly-50f70a75862c
Mastering Tabulate in Python: Create Beautiful Tables Effortlessly | by Sneha Jain | Medium
November 4, 2025 - This creates a new folder named venv containing a clean Python environment. ... from tabulate import tabulate data = [ ["Apple", 10], ["Banana", 5], ["Orange", 8], ["Grapes", 12], ["Mango", 7] ] print(tabulate(data))
Find elsewhere
🌐
GitHub
github.com › gregbanks › python-tabulate
GitHub - gregbanks/python-tabulate: fork of https://bitbucket.org/astanin/python-tabulate · GitHub
For tabulate, anything which can be parsed as a number is a number. Even numbers represented as strings are aligned properly. This feature comes in handy when reading a mixed table of text and numbers from a file: >>> import csv ; from StringIO import StringIO >>> table = list(csv.reader(StringIO("spam, 42\neggs, 451\n"))) >>> table [['spam', ' 42'], ['eggs', ' 451']] >>> print tabulate(table) ---- ---- spam 42 eggs 451 ---- ----
Starred by 188 users
Forked by 14 users
Languages   Python
🌐
GitHub
github.com › thruston › python-tabulate
GitHub - thruston/python-tabulate: A neat-text-table filter · GitHub
This verb provides an equivalent of the normal Python3 list method pop for the table. By default pop removes the last row, but you can use it to remove any row with the appropriate integer argument. For the purposes of pop the rows are zero indexed, so pop 0 will remove the top row, and the usual convention of negative indexes applies, so pop -1 will remove the last. Indexes that are too large are just ignored. Obviously if you are using tabulate from an editor you could just delete the row directly instead of use this command, but it is handy in certain idioms.
Author   thruston
🌐
GitHub
github.com › astanin › python-tabulate
GitHub - astanin/python-tabulate: Pretty-print tabular data in Python, a library and a command-line utility. Repository migrated from bitbucket.org/astanin/python-tabulate. · GitHub
In this case the command line utility will be installed to ~/.local/bin/tabulate on Linux and to %APPDATA%\Python\Scripts\tabulate.exe on Windows. To install just the library on Unix-like operating systems: ... The module provides just one function, tabulate, which takes a list of lists or another tabular data type as the first argument, and outputs a nicely formatted plain-text table:
Starred by 2.5K users
Forked by 186 users
Languages   Python
🌐
Analytics Vidhya
analyticsvidhya.com › home › comprehensive guide to python’s tabulate library
Comprehensive Guide to Python's Tabulate Library - Analytics Vidhya
May 29, 2025 - Creating basic tables using the `tabulate` library in Python is a straightforward process. The `tabulate` function takes a list of lists as input, where each inner list represents a row of the table, and an optional list for headers.
🌐
GitHub
github.com › thruston › python-tabulate › blob › master › README.md
python-tabulate/README.md at master · thruston/python-tabulate
The access to Python3 is not entirely general, as it is only intended for simple manipulation of a few values, and therefore tabulate tries quite hard to prevent you accidentally loading the sys module and deleting your disk. Only the following names of functions are allowed in a calculation. maths functions: abs cos cosd divmod exp floor hypot log log10 pow round sin sind sqrt tan tand ... The list functions are enhanced so you can call them with a tuple or a list of arguments.
Author   thruston
🌐
GitHub
github.com › zackdever › python-tabulate › blob › master › tabulate.py
python-tabulate/tabulate.py at master · zackdever/python-tabulate
>>> list(map(str,_align_column(["12.345", "-1234.5", "1.23", "1234.5", "1e+234", "1.0e234"], "decimal"))) [' 12.345 ', '-1234.5 ', ' 1.23 ', ' 1234.5 ', ' 1e+234 ', ' 1.0e234'] ... good_result = '\\u0431\\u0443\\u043a\\u0432\\u0430 \\u0446\\u0438\\u0444\\u0440\\u0430\\n------- -------\\n\\u0430\\u0437 2\\n\\u0431\\u0443\\u043a\\u0438 4' ; \ tabulate(tbl, headers=hrow) == good_result
Author   zackdever
🌐
AskPython
askpython.com › home › python tabulate module: how to easily create tables in python?
Python tabulate module: How to Easily Create Tables in Python? - AskPython
June 8, 2023 - Start by importing the module. You can then create a table by storing your data in a nested list and passing it to the tabulate function. To enhance the look of your table, use the tablefmt attribute and set it to grid ...
🌐
GitHub
github.com › cmck › python-tabulate
GitHub - cmck/python-tabulate · GitHub
In this case the command line utility will be installed to ~/.local/bin/tabulate on Linux and to %APPDATA%\Python\Scripts\tabulate.exe on Windows. To install just the library on Unix-like operating systems: ... The module provides just one function, tabulate, which takes a list of lists or another tabular data type as the first argument, and outputs a nicely formatted plain-text table:
Starred by 5 users
Forked by 2 users
Languages   Python
🌐
Snyk
snyk.io › advisor › tabulate › functions › tabulate.tabulate
How to use the tabulate.tabulate function in tabulate | Snyk
func_list = list(funcs.keys()) table = pd.DataFrame(final) table = table.reindex(table.mean(1).sort_values().index) order = np.log(table).mean().sort_values().index table = table.T table = table.reindex(order, axis=0) table = table.reindex(func_list, axis=1) table = 1000000 * table / (SIZE * NUMBER) table.index.name = "Bit Gen" print(table.to_csv(float_format="%0.1f")) try: from tabulate import tabulate perf = table.applymap(lambda v: "{0:0.1f}".format(v)) print(tabulate(perf, headers="keys", tablefmt="rst")) except ImportError: pass table = table.T rel = table.loc[:, ["NumPy"]].values @ np.ones((1, table.shape[1])) / table rel.pop("NumPy") rel = rel.T rel["Overall"] = np.exp(np.log(rel).mean(1)) rel *= 100 rel = np.round(rel).astype(np.int) rel.index.name = "Bit Gen" print(rel.to_csv(float_format=" ")) try: from tabulate import tabulate
🌐
Packetswitch
packetswitch.co.uk › how-to-create-tables-python-tabulate-module
How to Create Tables with Python Tabulate Module
April 26, 2024 - We'll use Python's Tabulate module to line up numbers to the right and show prices with just the right amount of decimal points. This is really handy when you're working with things like prices or quantities, and you want everything to be easy to read and compare. from tabulate import tabulate # Sample data: a list of dictionaries with numeric values data = [ {"Item": "Charger", "Quantity": 15, "Price": 89.2}, {"Item": "Case", "Quantity": 20, "Price": 19.507}, {"Item": "Cable", "Quantity": 10, "Price": 1.99} ] # Create a table with headers, aligning the columns and print it print(tabulate(data, headers="keys", numalign="right", floatfmt=".2f"))
🌐
Pythonrepo
pythonrepo.com › repo › astanin-python-tabulate-python-generating-and-working-with-logs
Pretty-print tabular data in Python, a library and a command-line utility. Repository migrated from bitbucket.org/astanin/python-tabulate. | PythonRepo
January 11, 2022 - In this case the command line utility will be installed to ~/.local/bin/tabulate on Linux and to %APPDATA%\Python\Scripts\tabulate.exe on Windows. To install just the library on Unix-like operating systems: ... The module provides just one function, tabulate, which takes a list of lists or another tabular data type as the first argument, and outputs a nicely formatted plain-text table: