From the docs for c it is used to

Combine Values into a Vector or List

In python you can combine values into a list using brackets so c(1, 2, 3) in R become [1, 2, 3] in Python. But if you didn't know this, I really urge you to stop porting the code and take two days to go through a basic Python tutorial. Understanding lists in Python is about as basic as you get.

The docs for tabulate state

tabulate takes the integer-valued vector bin and counts the number of times each integer occurs in it.

this sounds just like numpy's bincount

Count number of occurrences of each value in array of non-negative ints.

unless you have a requirement to also count negative ints? If not, it's pretty much a drop in replacement. So tabulate(c(2,3,3,5), nbins = 10) becomes np.bincount(np.array([2, 3, 3, 5]), minlength=10)

Answer from Dan on Stack Overflow
🌐
Medium
amrinarosyd.medium.com β€Ί prettytable-vs-tabulate-which-should-you-use-e9054755f170
PrettyTable vs. Tabulate: which should you use? | by Amrina Rosyada | Medium
May 8, 2023 - Both PrettyTable and Tabulate provide efficient performance for small to medium-sized datasets. However, for larger datasets, Tabulate is known to perform faster due to its more optimized codebase. PrettyTable is a popular Python library for creating visually appealing and easy-to-read American Standard Code for Information Interchange (ASCII) tables.
Discussions

Which is the most powerful Python module for tabulating content in command line?
🌐 r/Python
11
13
January 24, 2016
Python format tabular output - Stack Overflow
Using python2.7, I'm trying to print to screen tabular data. More on stackoverflow.com
🌐 stackoverflow.com
python - Printing Lists as Tabular Data - Stack Overflow
I am quite new to Python and I am now struggling with formatting my data nicely for printed output. I have one list that is used for two headings, and a matrix that should be the contents of the ta... More on stackoverflow.com
🌐 stackoverflow.com
python - Nicely tabulate a list of strings for printing - Code Review Stack Exchange
I have a list of strings of variable lengths, and I want to pretty-print them so they are lining up in columns. I have the following code, which works as I want it to currently, but I feel it is a... More on codereview.stackexchange.com
🌐 codereview.stackexchange.com
February 1, 2013
🌐
Stackshare
stackshare.io β€Ί pypi-tabulate β€Ί alternatives
tabulate Alternatives
Explore the pros & cons of tabulate and its alternatives. Learn about popular competitors like jQuery, React, and AngularJS
🌐
GitHub
github.com β€Ί zackdever β€Ί python-tabulate β€Ί blob β€Ί master β€Ί tabulate.py
python-tabulate/tabulate.py at master Β· zackdever/python-tabulate
"""Pretty-print tabular data.""" Β· from __future__ import print_function Β· from __future__ import unicode_literals Β· from collections import namedtuple, Iterable Β· from platform import python_version_tuple Β· import re Β· Β· Β· if python_version_tuple()[0] < "3": from itertools import izip_longest Β·
Author Β  zackdever
Find elsewhere
🌐
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
Given a 10x10 table (a list of lists) of mixed text and numeric data, tabulate appears to be faster than PrettyTable and texttable. The following mini-benchmark was run in Python 3.13.7 on Windows 11 (x64):
Starred by 2.5K users
Forked by 186 users
Languages Β  Python
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.

🌐
PyPI
pypi.org β€Ί project β€Ί tabulate
tabulate Β· PyPI
Given a 10x10 table (a list of lists) of mixed text and numeric data, tabulate appears to be faster than PrettyTable and texttable. The following mini-benchmark was run in Python 3.13.7 on Windows 11 (x64):
      Β» pip install tabulate
    
Published Β  Mar 04, 2026
Version Β  0.10.0
🌐
Arboreus
txt.arboreus.com β€Ί 2013 β€Ί 03 β€Ί 13 β€Ί pretty-print-tables-in-python.html
Pretty printing tables in Python
March 13, 2013 - I've published a Python pretty-printer library for tables. ... I used it across several projects, and decided it's time to package it properly. I often deal with tabular data in Python (a list of lists, a NumPy array), and from time to time I want to print it quickly, easily and in a reasonable ...
🌐
Medium
medium.com β€Ί @HeCanThink β€Ί tabulate-your-go-to-solution-for-stylish-tables-in-python-35ede5145e28
Tabulate: Your Go-To Solution for Stylish Tables in Python πŸ‘‰ | by Manoj Das | Medium
August 19, 2023 - Tabulate: Your Go-To Solution for Stylish Tables in Python πŸ‘‰ What is Tabulate? How to create formatted tabular data in Python. Tabulate in Python is a popular package that allows you to easily …
🌐
Towards Data Science
towardsdatascience.com β€Ί home β€Ί latest β€Ί 3 simple ways to quick generate text-based tables in python
3 Simple Ways to Quick Generate Text-based Tables in Python | Towards Data Science
January 20, 2025 - Tabulate is another library I’d like to recommend. Basically, it is pretty similar to PrettyTable, but I think it is more flexible in customizing the grid compared to PrettyTable.
🌐
LearnPython.com
learnpython.com β€Ί blog β€Ί print-table-in-python
How to Pretty-Print Tables in Python | LearnPython.com
When you finish the exploratory data analysis phase, you may want to make your tables look nicer. Two libraries provide the functionality to pretty print comma-separated values (CSV) in Python: tabulate and prettytable.
🌐
GitHub
github.com β€Ί cmck β€Ί python-tabulate
GitHub - cmck/python-tabulate Β· GitHub
In the same time tabulate is comparable to other table pretty-printers. Given a 10x10 table (a list of lists) of mixed text and numeric data, tabulate appears to be slower than asciitable, and faster than PrettyTable and texttable The following mini-benchmark was run in Python 3.5.2 on Windows
Starred by 5 users
Forked by 2 users
Languages Β  Python
🌐
LibHunt
libhunt.com β€Ί r β€Ί python-tabulate
Python-tabulate Alternatives and Reviews
Which is the best alternative to python-tabulate? Based on common mentions it is: Scrcpy, Pandoc, Pandas, Starship, Powerlevel10k, Rich, Typst, Exa, Typer or Hyperterm
Top answer
1 of 4
27

I seem to be having good output with prettytable:

from prettytable import PrettyTable
x = PrettyTable(dat.dtype.names)
for row in dat:
    x.add_row(row)
# Change some column alignments; default was 'c'
x.align['column_one'] = 'r'
x.align['col_two'] = 'r'
x.align['column_3'] = 'l'

And the output is not bad. There is even a border switch, among a few other options:

>>> print(x)
+------------+---------+-------------+
| column_one | col_two | column_3    |
+------------+---------+-------------+
|          0 |  0.0001 | ABCD        |
|          1 |   1e-05 | ABCD        |
|          2 |   1e-06 | long string |
|          3 |   1e-07 | ABCD        |
+------------+---------+-------------+
>>> print(x.get_string(border=False))
 column_one  col_two  column_3  
          0   0.0001  ABCD        
          1    1e-05  ABCD        
          2    1e-06  long string 
          3    1e-07  ABCD        
2 of 4
21

The tabulate package works nicely for Numpy arrays:

import numpy as np
from tabulate import tabulate

m = np.array([[1, 2, 3], [4, 5, 6]])
headers = ["col 1", "col 2", "col 3"]

# Generate the table in fancy format.
table = tabulate(m, headers, tablefmt="fancy_grid")

# Show it.
print(table)

Output:

╒═════════╀═════════╀═════════╕
β”‚   col 1 β”‚   col 2 β”‚   col 3 β”‚
β•žβ•β•β•β•β•β•β•β•β•β•ͺ═════════β•ͺ═════════║
β”‚       1 β”‚       2 β”‚       3 β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚       4 β”‚       5 β”‚       6 β”‚
β•˜β•β•β•β•β•β•β•β•β•β•§β•β•β•β•β•β•β•β•β•β•§β•β•β•β•β•β•β•β•β•β•›

The package can be installed from PyPI using e.g.

$ pip install tabulate