Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 从pandas设置html表格的样式_Python 3.x_Pandas_Dataframe - Fatal编程技术网

Python 3.x 从pandas设置html表格的样式

Python 3.x 从pandas设置html表格的样式,python-3.x,pandas,dataframe,Python 3.x,Pandas,Dataframe,我有一个很长的数据帧,我想发送给Gmail用户。我使用的方法是使用pd.to_html()。虽然我取得了成功,但这张表很长,可读性不强。首先,由于有如此多的行和列(是一个多列级别的表),索引和列名将消失,并且您不再能够知道每一列来自何处。此外,我错过了根据我要查找的内容进一步筛选表的可能性 我见过这样的东西添加到你的html表中,但我不知道如何使用我的脚本,因为它可能会在gmail帐户上可视化,而不是在浏览器上(也许解决方案是发送html文件,而不是嵌入表) 此外,我想使索引和列静态s,如果我向

我有一个很长的数据帧,我想发送给Gmail用户。我使用的方法是使用
pd.to_html()
。虽然我取得了成功,但这张表很长,可读性不强。首先,由于有如此多的行和列(是一个多列级别的表),索引和列名将消失,并且您不再能够知道每一列来自何处。此外,我错过了根据我要查找的内容进一步筛选表的可能性

我见过这样的东西添加到你的html表中,但我不知道如何使用我的脚本,因为它可能会在gmail帐户上可视化,而不是在浏览器上(也许解决方案是发送html文件,而不是嵌入表)

此外,我想使索引和列静态s,如果我向下滚动或横向滚动,我仍然可以看到他们

如何实现这一点

编辑:我找到了这个线程,它或多或少满足了我的需求。不过,我不知道如何在
pd.to\u html()上实现它。

编辑2:我做了finalframe.to_html(),这里是字符串的一小部分,包括标题和第一行数据

'<table border="1" class="dataframe">\n  <thead>\n    <tr>\n      <th>generales</th>\n      <th>fecha</th>\n      <th>competicion</th>\n      <th>local</th>\n      <th>visitante</th>\n      <th>tracker</th>\n      <th colspan="44" halign="left">local</th>\n      <th colspan="44" halign="left">visitante</th>\n      <th>Predicciones</th>\n    </tr>\n    <tr>\n      <th>h/a o totales</th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th colspan="22" halign="left">h/a</th>\n      <th colspan="22" halign="left">totales</th>\n      <th colspan="22" halign="left">h/a</th>\n      <th colspan="22" halign="left">totales</th>\n      <th></th>\n    </tr>\n    <tr>\n      <th>tipo de dato</th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th colspan="14" halign="left">medias</th>\n      <th colspan="8" halign="left">porcentajes</th>\n      <th colspan="14" halign="left">medias</th>\n      <th colspan="8" halign="left">porcentajes</th>\n      <th colspan="14" halign="left">medias</th>\n      <th colspan="8" halign="left">porcentajes</th>\n      <th colspan="14" halign="left">medias</th>\n      <th colspan="8" halign="left">porcentajes</th>\n      <th></th>\n    </tr>\n    <tr>\n      <th>dato</th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th>partidos</th>\n      <th>puntos por partido</th>\n      <th>Goles a favor</th>\n      <th>desv GAF</th>\n      <th>Goles en contra</th>\n      <th>desv GEC</th>\n      <th>Goles HT favor</th>\n      <th>desv GHTF</th>\n      <th>Goles HT contra</th>\n      <th>desv GHTC</th>\n      <th>Corner a favor</th>\n      <th>desv CAF</th>\n      <th>Corner en contra</th>\n      <th>desv CEC</th>\n      <th>o2,5</th>\n      <th>o3,5</th>\n      <th>Gol al HT a favor</th>\n      <th>Gol al HT en contra</th>\n      <th>Gol al HT</th>\n      <th>fts</th>\n      <th>cs</th>\n      <th>bts</th>\n      <th>partidos</th>\n      <th>puntos por partido</th>\n      <th>Goles a favor</th>\n      <th>desv GAF</th>\n      <th>Goles en contra</th>\n      <th>desv GEC</th>\n      <th>Goles HT favor</th>\n      <th>desv GHTF</th>\n      <th>Goles HT contra</th>\n      <th>desv GHTC</th>\n      <th>Corner a favor</th>\n      <th>desv CAF</th>\n      <th>Corner en contra</th>\n      <th>desv CEC</th>\n      <th>o2,5</th>\n      <th>o3,5</th>\n      <th>Gol al HT a favor</th>\n      <th>Gol al HT en contra</th>\n      <th>Gol al HT</th>\n      <th>fts</th>\n      <th>cs</th>\n      <th>bts</th>\n      <th>partidos</th>\n      <th>puntos por partido</th>\n      <th>Goles a favor</th>\n      <th>desv GAF</th>\n      <th>Goles en contra</th>\n      <th>desv GEC</th>\n      <th>Goles HT favor</th>\n      <th>desv GHTF</th>\n      <th>Goles HT contra</th>\n      <th>desv GHTC</th>\n      <th>Corner a favor</th>\n      <th>desv CAF</th>\n      <th>Corner en contra</th>\n      <th>desv CEC</th>\n      <th>o2,5</th>\n      <th>o3,5</th>\n      <th>Gol al HT a favor</th>\n      <th>Gol al HT en contra</th>\n      <th>Gol al HT</th>\n      <th>fts</th>\n      <th>cs</th>\n      <th>bts</th>\n      <th>partidos</th>\n      <th>puntos por partido</th>\n      <th>Goles a favor</th>\n      <th>desv GAF</th>\n      <th>Goles en contra</th>\n      <th>desv GEC</th>\n      <th>Goles HT favor</th>\n      <th>desv GHTF</th>\n      <th>Goles HT contra</th>\n      <th>desv GHTC</th>\n      <th>Corner a favor</th>\n      <th>desv CAF</th>\n      <th>Corner en contra</th>\n      <th>desv CEC</th>\n      <th>o2,5</th>\n      <th>o3,5</th>\n      <th>Gol al HT a favor</th>\n      <th>Gol al HT en contra</th>\n      <th>Gol al HT</th>\n      <th>fts</th>\n      <th>cs</th>\n      <th>bts</th>\n      <th>Poisson o25</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>2018/08/28 10:30</td>\n      <td>ALG U21</td>\n      <td>CS Constantine U21</td>\n      <td>JS Saoura U21</td>\n      <td>1611191</td>\n      <td>1</td>\n      <td>3.000000</td>\n      <td>2.000000</td>\n      <td>0.000000</td>\n      <td>1.000000</td>\n      <td>0.000000</td>\n      <td>1.000000</td>\n      <td>0.000000</td>\n      <td>1.000000</td>\n      <td>0.000000</td>\n      <td>2.000000</td>\n      <td>0.000000</td>\n      <td>4.000000</td>\n      <td>0.000000</td>\n      <td>1.000000</td>\n      <td>0.000000</td>\n      <td>1.000000</td>\n      <td>1.000000</td>\n      <td>1.000000</td>\n      <td>0.000000</td>\n      <td>0.000000</td>\n      <td>1.000000</td>\n      <td>1</td>\n      <td>3.000000</td>\n      <td>2.000000</td>\n      <td>0.000000</td>\n      <td>1.000000</td>\n      <td>0.000000</td>\n      <td>1.000000</td>\n      <td>0.000000</td>\n      <td>1.000000</td>\n      <td>0.000000</td>\n      <td>2.000000</td>\n      <td>0.000000</td>\n      <td>4.000000</td>\n      <td>0.000000</td>\n      <td>1.000000</td>\n      <td>0.000000</td>\n      <td>1.000000</td>\n      <td>1.000000</td>\n      <td>1.000000</td>\n      <td>0.000000</td>\n      <td>0.000000</td>\n      <td>1.000000</td>\n      <td>1</td>\n      <td>0.000000</td>\n      <td>0.000000</td>\n      <td>0.000000</td>\n      <td>3.000000</td>\n      <td>0.000000</td>\n      <td>0.00</td>\n      <td>0.000000</td>\n      <td>2.000000</td>\n      <td>0.000000</td>\n      <td>6.000000</td>\n      <td>0.000000</td>\n      <td>1.000000</td>\n      <td>0.000000</td>\n      <td>1.000000</td>\n      <td>0.000000</td>\n      <td>0.000000</td>\n      <td>1.000000</td>\n      <td>1.000000</td>\n      <td>1.000000</td>\n      <td>0.000000</td>\n      <td>0.000000</td>\n      <td>2</td>\n      <td>1.500000</td>\n      <td>1.000000</td>\n      <td>1.000000</td>\n      <td>1.500000</td>\n      <td>1.500000</td>\n      <td>1.000000</td>\n      <td>1.000000</td>\n      <td>1.000000</td>\n      <td>1.000000</td>\n      <td>4.500000</td>\n      <td>1.500000</td>\n      <td>2.500000</td>\n      <td>1.500000</td>\n      <td>0.500000</td>\n      <td>0.000000</td>\n      <td>0.500000</td>\n      <td>0.500000</td>\n      <td>1.000000</td>\n      <td>0.50</td>\n      <td>0.500000</td>\n      <td>0.000000</td>\n      <td>0.576810</td>\n    </tr>\n'
'\n\n\n一般情况\n fecha\n竞争\n本地\n访问\n跟踪器\n本地\n访问\n预测\n\n\n h/a o总计\n\n\n\n h/a\n总计\n h/a\n总计\n总计\n\n\n\n\n蒂波数据\n\n\n\n\n\n\n medias\n porcentajes\n medias\n porcentajes\n medias\n porcentajes\n\n\n dato\n\n\n\n\n\n partidos\n puntos por partido\n Goles a Goles a love \n desv GAF\n Goles en contra\n desv GEC\n Go这是一个很好的例子,它是一个很好的例子。它是一个很好的例子。它是一个很好的例子。它是一个很好的例子AF\n Goles en contra\n desv GEC\n Goles HT offer\n desv GHTF\n Goles HT contra\n desv GHTC\n Corner a offer\n desv CAF\n Corner en contra\n desv CEC\n o2,5\n o3,5\n Gol al HT a offer\n Gol al HT en contra\n Gol al HT\n fts\n cs\n bts\n partidos\n puntos por partido\n Goles a FORMANCE\n desv GAF\n Goles en contra\n desv GEC\n Goles HT FORMANCE\n desv GHTF\n Goles HT contra\n desv GHTC\n Corner a FORMANCE\n desv CAF\n Corner en contra\n desv CEC\n o2,5\n o3,5\n Gol al HT a FORMANAGE\n Gol HT en contra\n Gol HT\n Gol HT IN al HT\n Gol HT IN al al HT al HT IN al HT\n Gol HT Gol HT\nfts\n cs\n bts\n partidos\n puntos por partido\n Goles a off\n desv GAF\n Goles en contra\n desv GEC\n Goles HT off\n desv GHTF\n Goles HT contra\n desv GHTC\n Corner a off\n desv CAF\n Corner in contra\n desv CEC\n o2,5\n o3,5\n Gol a off\n Gol al HT en contra\n Gol al HT\n fts\n cs\n bts\n Poisson o25\n\n\n\n 0\n 2018/08/28 10:30\n ALG U21\n cs Constantine U21\n JS Saoura U21\n 1611191\n 1\n 3.000000\n 2.000000\n 0.000000\n 1.000000\n 0.000000\n 1.000000\n 0.000000\n1.000000\n 0.000000\n 2.000000\n 0.000000\n 4.000000\n 0.000000\n 1.000000\n 1.000000\n 1.000000\n 0.000000\n 0.000000\n 0.000000\n 1.000000\n 1\n 3.000000\n 2.000000\n 0.000000\n 1.000000\n 0.000000\n 1.000000\n 0.000000\n1.000000\n 0.000000\n 2.000000\n 0.000000\n 4.000000\n 0.000000\n 1.000000\n 1.000000\n 1.000000\n 0.000000\n 0.000000\n 0.000000\n 1.000000\n 1\n 0.000000\n 0.000000\n 0.000000\n 3.000000\n 0.000000\n 0.000000\n 0.000000\n 2.000000\n 0.000000\n 6.000000\n 0.000000\n 1.000000\n 0.000000\n 0.000000\n 1.000000\n 1.000000\n 1.000000\n 1.000000\n 0.000000\n 0.000000\n 2\n 1.500000\n 1.000000\n 1.500000\n 1.500000\n 1.500000\n 1.500000\n 1.000000\n1.000000\n 4.500000\n 1.500000\n 2.500000\n 1.500000\n 0.500000\n 0.000000\n 0.500000\n 0.500000\n 1.000000\n 0.50\n 0.500000\n 0.000000\n 0.576810\n\n

你能提供一些例子吗?你的输入是什么样子的?你希望输出是什么样子的?我今晚会试试。但它只是一个300x90矩阵,当你向下滚动时,列就看不见了,向右滚动时索引也看不见了。我想要的是,使用
到\u html()
或通过其他方式,可以像我提供的链接中的表那样筛选表,并使列和索引始终可见,这或多或少与Excel表类似。我只是提供了额外的信息