Pandas 数据框隐藏索引功能? [英] Pandas dataframe hide index functionality?

查看:32
本文介绍了Pandas 数据框隐藏索引功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在显示 Pandas 数据框时隐藏索引,以便只有列名出现在表的顶部?

Is it possible to hide the index when displaying pandas dataframes, so that only the column names appear at the top of the table?

这需要同时适用于 ipython notebook 中的 html 表示和 to_latex() 函数(我与 nbconvert 一起使用).

This would need to work for both the html representation in ipython notebook and to_latex() function (which I'm using with nbconvert).

塔.

推荐答案

Set index=False

对于 ipython 笔记本:

For ipython notebook:

print df.to_string(index=False)

对于 to_latex:

For to_latex:

df.to_latex(index=False)

这篇关于Pandas 数据框隐藏索引功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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