Pandas Dataframe to HTML remove index Pandas Dataframe to HTML remove index flask flask

Pandas Dataframe to HTML remove index


As mentioned by @ayhan in the comments you can use .to_html(index=False) to surpress the index to be included in the html table.

Just posted it because not everyone might see the comment.


As mentioned here, one can now use the "hide_index()" function in Pandas (see https://pandas.pydata.org/pandas-docs/stable/style.html#Hiding-the-Index-or-Columns) just before calling "render()":

def highlight_oddRow(s):    return ['background-color: yellow' if s.name % 2 else '' for v in s]table = pd.DataFrame(    {'a': [1,2,3,4,5], 'b': [6,7,8,9,10]})with open ('out.html','w') as out:    print >> out, table.style.apply(highlight_oddRow,axis=1).hide_index().render()