Reputation: 7790
I have the following tab delimited file (mydata.txt
):
Set Coolthing Route Organ Up Down
set4 foo ID LN 81 60
set4 bar ID LN 542 92
set4 foo ID LV 73 73
set4 bar ID LV 143 78
set4 foo ID SP 32 82
set4 bar ID SP 90 129
And with the following code:
import pandas as pd
df = pd.io.parsers.read_table("http://dpaste.com/3ZTTVQH.txt")
df = df.pivot(index="Coolthing",columns="Organ")
df.drop('Set',axis=1,inplace=True)
df.drop('Route',axis=1,inplace=True)
I have the following data frame:
In [15]: df
Out[15]:
Up Down
Organ LN LV SP LN LV SP
Coolthing
bar 542 143 90 92 78 129
foo 81 73 32 60 73 82
Then using df.to_html(index=True, justify="left")
create this html:
What I want to do is to remove the index names Organ
and Coolthing
. Resulting this:
Up Down
LN LV SP LN LV SP
bar 542 143 90 92 78 129
foo 81 73 32 60 73 82
How can I achieve that?
Upvotes: 10
Views: 6608
Reputation: 976
You can just get/set the index via its name property. What you can do is set
df.index.name = ""
Upvotes: 0
Reputation: 394021
There is a name
for single level names and names
for multi-level names so for your example you need to do this to clear the names from index and columns:
In [372]:
df.index.name = None
df.columns.names = (None,None)
df
Out[372]:
Up Down
LN LV SP LN LV SP
bar 542 143 90 92 78 129
foo 81 73 32 60 73 82
Upvotes: 13