JS数据表从 pandas [英] JS dataTables from pandas

查看:113
本文介绍了JS数据表从 pandas 的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用数据表使用大熊猫数据帧。我不知道如何初始化没有ID的表。

I want to use pandas dataFrames with dataTables. I cannot figure out how to initialize the table without an id.

当我调用df.to_html()?有没有办法在表格标签中设置id?

Is there any way to set the id in the table tag when I call df.to_html()?

推荐答案

你可以试试这个:

df.to_html(classes = 'my_class" id = "my_id')

基本上就像一个SQL注入。

熊猫 to_html函数在类周围使用双引号。您可以使用单引号定义classes参数,并在其中放置双引号以结束熊猫的类。然后在你的id名字上打开双引号,但让大熊猫把你的双引号关闭。输出结果如下:

It's like a SQL injection basically.
Pandas' to_html function uses double quotes around the class. You can use single quotes to define the classes argument, and put double quotes inside them to end pandas' class. Then put opening double quotes around your id name but let pandas' close those double quotes for you. The output will be the following:

'<table border="1" class="dataframe my_class" id = "my_id">...'

希望有所帮助。

这篇关于JS数据表从 pandas 的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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