Skip to main content

A python package with helpful tools when working with the rich python library.

Project description

🔧 Rich Tools

Tests

A python package with helpful tools when working with the rich python library.

The current features are:

  • Convert a Pandas DataFrame into a rich Table.

    By making this conversion, we can now pretty print a DataFrame in the terminal with rich. Bridging the gap between pandas and rich also provides a path for loading external data into a rich Table using Pandas functions such as .from_csv()!

  • Convert a rich Table into a Pandas DataFrame.

    By bridging the gap between a rich Table and a DataFrame, we can now take additional actions on our data such as
    saving the data to a csv using the Pandas function .to_csv()!

Installation

$ pip install rich-tools

Example

Additional examples can be found in the examples dir.

from datetime import datetime

import pandas as pd
from rich import box
from rich.console import Console
from rich.table import Table

from rich_tools.table import df_to_table

console = Console()


if __name__ == "__main__":
    sample_data = {
        "Date": [
            datetime(year=2019, month=12, day=20),
            datetime(year=2018, month=5, day=25),
            datetime(year=2017, month=12, day=15),
        ],
        "Title": [
            "Star Wars: The Rise of Skywalker",
            "[red]Solo[/red]: A Star Wars Story",
            "Star Wars Ep. VIII: The Last Jedi",
        ],
        "Production Budget": ["$275,000,000", "$275,000,000", "$262,000,000"],
        "Box Office": ["$375,126,118", "$393,151,347", "$1,332,539,889"],
    }
    df = pd.DataFrame(sample_data)

    # Initiate a Table instance to be modified
    table = Table(show_header=True, header_style="bold magenta")

    # Modify the table instance to have the data from the DataFrame
    table = df_to_table(df, table)

    # Update the style of the table
    table.row_styles = ["none", "dim"]
    table.box = box.SIMPLE_HEAD

    console.print(table)

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

rich-tools-0.1.2.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

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

rich_tools-0.1.2-py3-none-any.whl (3.0 kB view details)

Uploaded Python 3

File details

Details for the file rich-tools-0.1.2.tar.gz.

File metadata

  • Download URL: rich-tools-0.1.2.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.11 CPython/3.10.0 Windows/10

File hashes

Hashes for rich-tools-0.1.2.tar.gz
Algorithm Hash digest
SHA256 08a6f82597610fde34638f06c956fea3d58dd5707a31a09e409375a24b9fc715
MD5 2f2d9bf7201ac6f89e8be57562cb881e
BLAKE2b-256 6343b4df30a426eb264953cf4e213701eb307b0b04be2a1e60b7484d46931c8c

See more details on using hashes here.

File details

Details for the file rich_tools-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: rich_tools-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 3.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.11 CPython/3.10.0 Windows/10

File hashes

Hashes for rich_tools-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3ac831f0c09f93b6d20bdfe70d629fef0eafb9505bce5ffe96696c1bed266daa
MD5 46543d688653a40148b7c4e7045f0fe9
BLAKE2b-256 ccd74e8cef9724526eff9d4f8a7e16d8bdb280c481cc70a5f4080bf3ccd40eb6

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