Skip to content

PetitLepton/table_styler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

table_styler

This is a simple custom styler for tables, inspired by this Medium post and this UX talk, based on the following rules:

  • text (and dates) items should be aligned left;
  • headings should be easily recognized from the items.

The following example

(
    TableStyler(
        pandas.DataFrame(
            data={
                "Text column": 3
                * [
                    "This is not long enough, it needs to be really much longer to show a line break. This hopefully should do the trick as expected."
                ]
                + 3 * ["This is short"],
                "Number column": 3 * [91] + 3 * [1243],
                "Another Number column": 3 * [91] + 3 * [1243],
                "Date column quite long": pandas.date_range(
                    start="1970-01-01", periods=6, freq="d"
                ),
            }
        )
        .hide_index()
        .format_columns(numerical_format="{:,}", date_format="{:%b %d, %Y}")
        .render()
    )
)

will render in a browser as

About

Custom styler for tables with pandas

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages