Skip to main content

Make pandas dataframe looking pretty again

Project description

pretty_html_table - Beautiful html tables made easy

Detailed usage documentation is still in progress The objective of this package is to convert a pandas dataframe into a pretty html table. As of now, 10 colors are available. This package is embedding very nicely with other packages used to send emails. The format is set down to the line item, which allows it to be understood by every email providers (instead of using CSS style).

This is how you can install it on your machine:

pip install pretty_html_table

This is for example how you can convert your dataframe:

from pretty_html_table import build_table
html_table_blue_light = build_table(pd.read_excel('df.xlsx'), 'blue_light')
print(html_table_blue_light)

Why choose pretty_html_table?

It integrates very well with other python packages used to send emails. Just add the result of this package to the body of the email and voila.

List of colors available

Name font style Header Rows
'blue_light' Century Gothic Bold: yes / Background color: white / Font color: dark blue Odd background color: light blue / Even background color: white
'blue_dark' Century Gothic Bold: yes / Background color: dark blue / Font color: white Odd background color: light blue / Even background color: white
'grey_light' Century Gothic Bold: yes / Background color: white / Font color: dark grey Odd background color: light grey / Even background color: white
'grey_dark' Century Gothic Bold: yes / Background color: dark grey / Font color: white Odd background color: light grey / Even background color: white
'orange_light' Century Gothic Bold: yes / Background color: white / Font color: dark orange Odd background color: light orange / Even background color: white
'orange_dark' Century Gothic Bold: yes / Background color: dark orange / Font color: white Odd background color: light orange / Even background color: white
'yellow_light' Century Gothic Bold: yes / Background color: white / Font color: dark yellow Odd background color: light yellow / Even background color: white
'yellow_dark' Century Gothic Bold: yes / Background color: dark yellow / Font color: white Odd background color: light yellow / Even background color: white
'green_light' Century Gothic Bold: yes / Background color: white / Font color: dark green Odd background color: light green / Even background color: white
'green_dark' Century Gothic Bold: yes / Background color: dark green / Font color: white Odd background color: light green / Even background color: white
'red_light' Century Gothic Bold: yes / Background color: white / Font color: dark red Odd background color: light red / Even background color: white
'red_dark' Century Gothic Bold: yes / Background color: dark red / Font color: white Odd background color: light red / Even background color: white

Example of an integration with the O365 package

O365

First, we create a function to send an email:

import O365
from O365 import Account

credentials = (o365credid, o365credpwd)
account = Account(credentials)

def send_email(account, to, subject, start, body, end):
    m = account.new_message()
    m.to.add(to)
    m.subject = subject
    m.body = start + body + end
    m.send()

Then we can write the start of an email and the end of the email using the html language:

start = """<html>
                <body>
                    <strong>There should be an table here:</strong></br>"""


end = """</body>
    </html>
    """

Finally we can can pretty_table_html package and send the email:

from pretty_html_table import build_table

html_table_blue_light = build_table(pd.read_excel('df.xlsx'), 'blue_light')

send_email(account
           , 'test@any.com'
           , 'test table'
           , start
           , html_table_blue_light
           , end)

Here are all of the currently available colors:

Light Dark

Additional arguments

Since we created this library, we have added serveral optional arguments that we hope willl help you:

build_table(df, color, font_size = 'medium', font_family = 'Century Gothic', text_align = 'left')

You can now decide on the font, the size and the alignment of the text.

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

pretty_html_table-0.9.3.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

pretty_html_table-0.9.3-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file pretty_html_table-0.9.3.tar.gz.

File metadata

  • Download URL: pretty_html_table-0.9.3.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.2

File hashes

Hashes for pretty_html_table-0.9.3.tar.gz
Algorithm Hash digest
SHA256 4a0b6467b842473f4cbe9e95156b0b7cba3d1de48a8bf879270ae65f8899eff3
MD5 83eb83516479c27354b33737caa8c08b
BLAKE2b-256 ab7922783f5dfe6765607420e0173f9494914f38b09cd2d732b82d58bea8aa08

See more details on using hashes here.

File details

Details for the file pretty_html_table-0.9.3-py3-none-any.whl.

File metadata

  • Download URL: pretty_html_table-0.9.3-py3-none-any.whl
  • Upload date:
  • Size: 4.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.2

File hashes

Hashes for pretty_html_table-0.9.3-py3-none-any.whl
Algorithm Hash digest
SHA256 65b40a8497b5864bfd5b77ac49a78e923b1f83bfffff422deb093cd2b7547301
MD5 55bea4b0dc9c1aa4f3b9ce3b3b341032
BLAKE2b-256 e14c1e8f88c2b1eb8fb3c3f03de1d52648e3f09d5afff4d38777b4d36f00b559

See more details on using hashes here.

Supported by

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