pandas -删除列索引的标签 [英] Pandas - remove the label of the column index
本文介绍了 pandas -删除列索引的标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个数据框,如下所示:
I have a dataframe as follows:
PLEASE_REMOVE 2013 2014 2015
THIS_IS_EASY
-------------------------------
Bob 0 3 4
Mary 2 3 6
年份(2013、2014、2015)是列索引标签.名称(Mary,Bob)是行索引标签.
The years (2013, 2014, 2015) are the column index labels. The names (Mary, Bob) are the row index labels.
我已经设法设法获得行索引和列索引的标签.
I have somehow managed to get labels for the row indices and column indices.
使用 df.index.names = ['']
,我可以删除THIS_IS_EASY位.
Using df.index.names = ['']
I can remove the THIS_IS_EASY bit.
如何删除PLEASE_REMOVE位?
How can I remove the PLEASE_REMOVE bit?
所需的输出是:
2013 2014 2015
-------------------------------
Bob 0 3 4
Mary 2 3 6
推荐答案
Ian Logie提交的熊猫1.x的新答案,>
df.columns.name = None
只需删除列名:
del df.columns.name
此外,请注意, df.index.names = ['']
与 del df.index.name
不太相同.
Also, note that df.index.names = ['']
is not quite the same as del df.index.name
.
这篇关于 pandas -删除列索引的标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文