Pandas dataframe hide index functionality?
As has been pointed out by @waitingkuo, index=False is what you need. If you want to keep the nice table layout within your ipython notebook, you can use:
from IPython.display import display, HTML
display(HTML(df.to_html(index=False)))
Starting from v. 0.17.1 it is possible to hide the index via styling, see hiding the index or colums: if df
is your Data Frame just do
df.style.hide_index()
Please note that styling works only in the notebook, and not within the LaTeX conversion.
I added the following cell to my notebook which works fine in Jupyter 4.0.2.
Note: It removes the first column of 'any' table even when there is no index.
# Execute this cell to remove the first column of dataframe tables (to remove index column)
from IPython.core.display import HTML
HTML("""
<style>
table.dataframe thead th:first-child {
display: none;
}
table.dataframe tbody th {
display: none;
}
</style>
""")
Set index=False
For ipython notebook:
print df.to_string(index=False)
For to_latex:
df.to_latex(index=False)