从通过 pandas 创建的html表中删除边框 [英] Remove border from html table created via pandas

查看:150
本文介绍了从通过 pandas 创建的html表中删除边框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用python脚本在网页上显示数据框。我使用 df.to_html 将我的数据框转换为HTML。但是,默认情况下,它将边框设置为0.我尝试通过定制css模板覆盖它,但它不起作用。



这是我的熊猫代码:

  ricSubscription.to_html(classes ='mf')

是否有一个参数可以在调用此函数时将border设置为零?

解决方案

to_html()生成< table border =1class =dataframe> ... $ b

你可以这样做:

  ricSubscription。 to_html()。replace('border =1','border =0')

另外,要具体回答,似乎没有任何事情可以通过。 border =1似乎是硬编码的: $ b

https://github.com/pydata/pandas/blob/e4cb0f8a6cbb5f0c89b24783baa44326e4b2cccb/pandas/core/format.py#L893


I am using a python script to display dataframe on a webpage. I used df.to_html to convert my dataframe to HTML. However, by default, it sets the border to 0. I tried overriding it by having a custom css template but it didn't work.

Here is my pandas code:

ricSubscription.to_html(classes='mf')

Is there a parameter I can pass to set the border to zero while making this call?

解决方案

to_html() generates <table border="1" class="dataframe">...

You could just do:

ricSubscription.to_html().replace('border="1"','border="0"')

Also, to answer specifically, there does not appear to be anything you can pass. border="1" appears to be hardcoded:

https://github.com/pydata/pandas/blob/e4cb0f8a6cbb5f0c89b24783baa44326e4b2cccb/pandas/core/format.py#L893

这篇关于从通过 pandas 创建的html表中删除边框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆