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
并使用以下代码:
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)
我有以下数据框:
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
然后使用df.to_html(index = True,justify =“left”)创建这个html:
我想要做的是删除索引名称Organ和Coolthing.结果如下:
Up Down
LN LV SP LN LV SP
bar 542 143 90 92 78 129
foo 81 73 32 60 73 82
我怎样才能做到这一点?
解决方法:
单级名称和多级名称的名称都有一个名称,因此对于您的示例,您需要执行此操作以清除索引和列中的名称:
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
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。