Pretty tables and matrices for Python
from ansitable import ANSITable
table = ANSITable("Name", "Score", border="thin")
table.row("Alice", 95)
table.row("Bob", 87)
table.row("Carol", 92)
table.print()Output:
┌───────┬───────┐
│ Name │ Score │
├───────┼───────┤
│ Alice │ 95 │
│ Bob │ 87 │
│ Carol │ 92 │
└───────┴───────┘
- Unicode and ANSI colors — Beautiful output in any ANSI-capable terminal
- 7 export formats — Markdown, HTML, LaTeX, reStructuredText, Wikitable, CSV, Pandas
- Rich styling — Colors, backgrounds, text styles (bold, underlined, etc.), alignment, width control
- Sorting — Sort tables by any column, with optional key function
- Pandas integration — Convert DataFrames to/from ANSITable
- Matrix formatting — Pretty-print NumPy arrays with brackets and styles
- Flexible API — Simple string-based or detailed Column-based column specification
pip install ansitableOptional dependency for colors:
pip install coloredSee the comprehensive documentation for tutorials, examples, and API reference.
