Skip to main content

R-style tibble() display for pandas DataFrames using Rich

Project description

pandas-tibble PyPI Version

Downloads

Display pandas DataFrames with R-style tibble formatting in the terminal.

What it does

  • Tibble class - a DataFrame subclass that preserves all pandas functionality with automatic tibble-style display
  • Prints DataFrames with column type annotations (<chr>, <int>, <dbl>, <date>, <datetime>)
  • Shows dimensions at the top
  • Distinguishes between date and datetime types
  • Provides glimpse() for quick column overview
  • All pandas operations work: .query(), .merge(), .groupby(), etc.

Installation

pip install pandas-tibble

For development:

git clone https://github.com/caspercrause/pandas-tibble.git
cd pandas-tibble
poetry install

Requirements

  • Python >= 3.10.0
  • pandas >= 2.0.0
  • rich >= 13.0.0

Usage

Tibble class (Recommended)

Create a DataFrame subclass with automatic beautiful display:

from pandas_tibble import Tibble

# Create a Tibble - displays automatically!
tbl = Tibble({
    'product': ['A', 'B', 'A', 'B'],
    'revenue': [100, 150, 120, 180],
    'units': [10, 12, 11, 15]
})

# Just evaluate it - beautiful display
tbl

# All pandas operations work and return Tibbles!
tbl.query('revenue > 110')
tbl['profit'] = tbl['revenue'] * 0.2
tbl.groupby('product').sum()
tbl.merge(other_tbl, on='product')

Output:

# A DataFrame: 4 × 3

product  revenue  units
<chr>    <int>    <int>
A        100      10
B        150      12
A        120      11
B        180      15

tibble() function (for printing purposes only)

Display any DataFrame with type annotations:

import pandas as pd
from pandas_tibble import tibble
from datetime import date

df = pd.DataFrame({
    'start_date': [date(2024, 1, i) for i in range(1, 6)],
    'name': ['Alice', 'Bob', 'Charlie', 'Diana', 'Eve'],
    'value': [100, 200, 300, 400, 500]
})

tibble(df)

Output:

# A DataFrame: 5 × 3

start_date  name     value
<date>      <chr>    <int>
━━━━━━━━━━━━━━━━━━━━━━━━━━━
2024-01-01  Alice    100
2024-01-02  Bob      200
2024-01-03  Charlie  300
2024-01-04  Diana    400
2024-01-05  Eve      500

Options:

tibble(df, max_rows=20)         # Show more rows
tibble(df, show_index=True)     # Include index column

glimpse()

Quick column overview:

glimpse(df)

Output:

Rows: 5
Columns: 3

start_date  <date>  2024-01-01, 2024-01-02, 2024-01-03...
name        <chr>   Alice, Bob, Charlie...
value       <int>   100, 200, 300...

Type mapping

pandas dtype Display Format
object (string) <chr> as-is
int64 <int> as-is
float64 <dbl> 2 decimals
bool <lgl> True/False
datetime64[ns] <datetime> YYYY-MM-DD HH:MM:SS
object (date) <date> YYYY-MM-DD
category <fctr> as-is
timedelta64[ns] <timedelta> as-is

Missing values display as NA.

Features

  • ✅ Full pandas compatibility - all methods preserved
  • ✅ Automatic beautiful display in terminal, Jupyter, VS Code
  • ✅ Operations return Tibble objects (.query(), .merge(), .groupby(), etc.)
  • ✅ Type annotations for all columns
  • ✅ Works with existing DataFrames via Tibble(df) conversion

What it doesn't do

  • Does not replicate R tibble's subsetting rules
  • Does not support tibble construction syntax (use dict or DataFrame syntax)
  • Does not modify how pandas operations work (100% compatible)

Similar Packages

Several packages provide enhanced DataFrame display or R-style functionality:

  • rich-dataframe: Creates animated and pretty DataFrames using Rich, but is display-only and does not create a DataFrame subclass
  • skimpy: Python port of R's skimr package, focuses on summary statistics rather than full tibble-style display
  • tabulate: General table formatting library used by pandas' to_markdown(), provides formatting without DataFrame integration
  • rich-tools: Helper functions to convert DataFrames to Rich tables for printing, not a DataFrame replacement
  • datar: Full tidyverse port to Python with complete API replacement and heavy dependencies

What Sets pandas-tibble Apart

pandas-tibble is the only package that combines all of the following:

  • DataFrame subclass that preserves all pandas methods and operations
  • Automatic R-style tibble display without explicit print calls
  • Lightweight implementation with only two dependencies (pandas and Rich)
  • All operations return Tibble objects, maintaining consistency throughout your workflow
  • Drop-in replacement for pandas DataFrames with zero API changes

Most packages are either display-only utilities or complete pandas replacements. pandas-tibble provides the best of both worlds: beautiful R-style display with full pandas compatibility.

License

MIT

Author

Casper Crause

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pandas_tibble-0.2.2.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pandas_tibble-0.2.2-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file pandas_tibble-0.2.2.tar.gz.

File metadata

  • Download URL: pandas_tibble-0.2.2.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.10.0 Darwin/24.6.0

File hashes

Hashes for pandas_tibble-0.2.2.tar.gz
Algorithm Hash digest
SHA256 7e3ef750433cacb0b8ed8b6f64371f86e835f7797248a4a590fe9a0f66eaa837
MD5 b2f8f057dc0cf894add17cbc06f73606
BLAKE2b-256 0b4d03ef48cf4f762713b0cae1ce8941e2df406708bb061065803fc25914e84f

See more details on using hashes here.

File details

Details for the file pandas_tibble-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: pandas_tibble-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 7.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.10.0 Darwin/24.6.0

File hashes

Hashes for pandas_tibble-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f1805baf4c496cda408a54e5141fcb7ab647c69397994039072bf161606d60cd
MD5 65ee3111ce84ce2fd3c59c59ffb8a20a
BLAKE2b-256 32b65bc3e0695f297a30588ce6ec6f9487a72d163b8e57d7125bdb3bcd71e91f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page