Git Product home page Git Product logo

rich_tools's Introduction

๐Ÿ”ง Rich Tools

A python package with helpful functions for use alongside with the rich python library.

PyPI version Supported Python Versions Test ๓ € ๓ €  Twitter


The current features are:

  • Convert a Pandas DataFrame into a rich Table โžœ df_to_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 โžœ table_to_df()

    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()!

  • Convert a rich Table into a list of dictionaries. โžœ table_to_dicts()

    Get your tables rows as a list of dictionaries with column names as key, and row contents as values.

  • Strip rich markup tags from a string. โžœ strip_markup_tags()

    Helper function to remove tags from text formatted with rich. "[bold]Bold[/bold]" becomes "Bold"

  • Export a rich table to HTML

    Currently there are 2 renderers for the tables using plain HTML or the tabulator js library.

Installation

$ pip install rich-tools

Extra configuration

  • Set the environment variable DISABLE_PANDAS to 1 if you don't want to load the pandas library. This is useful in environments with low memory like AWS lambda.

Example

Additional examples can be found in the examples dir.

# Print csv data to the terminal as a pretty printed rich formatted table

import pandas as pd
from rich import print
from rich_tools import df_to_table

if __name__ == '__main__':
    df = pd.read_csv("sample_input.csv")
    table = df_to_table(df)
    print(table)

Credits

  • Like the rich package itself, its creator Will McGugan is awesome! Check out Textual "a TUI (Text User Interface) framework for Python inspired by modern web development". Thank you for the advice you've given on this project! ๐Ÿ™
  • I am grateful for folks who give some of their time to this project in any form. Check out the list of contributors and learn more about contributing here.

rich_tools's People

Contributors

avi-perl avatar usltd avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.