pandas 转换为 html 表时删除熊猫数据框中的索引

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/46684358/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 04:37:06  来源:igfitidea点击:

Remove index in pandas data-frame while converting to html table

pythonpandasdataframeindexing

提问by arshpreet

I am trying to remove index while converting pandas data-frame into html table. Prototype is as follows:

我试图在将 Pandas 数据框转换为 html 表时删除索引。原型如下:

import pandas as pd
import numpy as np
df= pd.DataFrame({'list':np.random.rand(100)})
html_table = df.to_html()

In html table I don't want to display index.

在 html 表中我不想显示索引。

回答by Wei

Try this:

尝试这个:

html_table = df.to_html(index = False)

回答by jezrael

It seems you need remove index name:

看来您需要删除索引名称:

df = df.rename_axis(None)

Or:

或者:

df.index.name = None

For not display index use:

对于不显示索引使用:

print (df.to_string(index=False))