使pandas数据框看起来更漂亮

pretty-html-table的Python项目详细描述


pretty_html_table-使漂亮的html表格变得简单

详细的使用文档仍在进行中 这个包的目标是将pandas数据框架转换成一个漂亮的html表。 截至目前,有10种颜色可供选择。这个包与其他用来发送电子邮件的包嵌入得非常好。 格式被设置为行项目,这样每个电子邮件提供者都可以理解它(而不是使用css样式)。

这是您可以在计算机上安装它的方法:

pip install pretty_html_table

例如,这就是如何转换数据帧:

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

为什么选择漂亮的HTML表?

它与其他用于发送电子邮件的python包集成得非常好。只需将此包的结果添加到电子邮件的正文中,然后瞧。

可用颜色列表

Namefont styleHeaderRows
'blue_light'Century GothicBold: yes / Background color: white / Font color: dark blueOdd background color: light blue / Even background color: white
blue_dark'Century GothicBold: yes / Background color: dark blue / Font color: whiteOdd background color: light blue / Even background color: white
grey_light'Century GothicBold: yes / Background color: white / Font color: dark greyOdd background color: light grey / Even background color: white
grey_dark'Century GothicBold: yes / Background color: dark grey / Font color: whiteOdd background color: light grey / Even background color: white
orange_light'Century GothicBold: yes / Background color: white / Font color: dark orangeOdd background color: light orange / Even background color: white
orange_dark'Century GothicBold: yes / Background color: dark orange / Font color: whiteOdd background color: light orange / Even background color: white
yellow_light'Century GothicBold: yes / Background color: white / Font color: dark yellowOdd background color: light yellow / Even background color: white
yellow_dark'Century GothicBold: yes / Background color: dark yellow / Font color: whiteOdd background color: light yellow / Even background color: white
green_light'Century GothicBold: yes / Background color: white / Font color: dark greenOdd background color: light green / Even background color: white
green_dark'Century GothicBold: yes / Background color: dark green / Font color: whiteOdd background color: light green / Even background color: white

与o365包集成的示例

O365

首先,我们创建一个发送电子邮件的函数:

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

然后我们可以使用HTML语言编写电子邮件的开头和结尾:

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


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

最后,我们可以使用漂亮的HTML包发送电子邮件:

import ph_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)

以下是所有当前可用的颜色:

LightDark

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java exoplayer启用视频字幕   java在读取RSS源时“1字节UTF8序列的1字节无效”   在Array Android Java中维护最新的5个用户?   swing命令在Java actionperformed中运行了两次   使用java将数据从cassandra迁移到多个文件   java connect MySQL数据库与playframework 2.5   java无法在片段中的SimpleAdapter中创建getView   java有线scala类型设计   java谷歌云消息开发者安卓代码崩溃   java使用@NoRepositoryBean运行Spring集成测试,没有@Repository实现   java在使用抽象类时为@RequestBody指定类型   java如何返回数组的和,并使用以下代码启动它?   java DecryptoJS中不返回所需数据的解密   java如何解析xml并选择要发送的项目   Eclipse中的java Google Web工具包   java获取两个文本的相似度百分比