If I use DataFrame.set_index
, I get this result:
import pandas as pd
df = pd.DataFrame([[\'foo\',1,3.0],[\'bar\',2,2.9],
[\'
I poked around in the source for Styler and figured it out; if you set df.index.names = [None]
then this suppresses the "extra" row (along with the column header that I don't really care about):
import pandas as pd
df = pd.DataFrame([['foo',1,3.0],['bar',2,2.9],
['baz',4,2.85],['quux',3,2.82]],
columns=['name','order','gpa'])
df = df.set_index('name')
df.index.names = [None]
df
These days pandas actually has a keyword for this:
df.to_html(index_names=False)
https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.to_html.html