删除pandas中的索引名称 [英] Remove index name in pandas

查看:2501
本文介绍了删除pandas中的索引名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个类似这样的数据框:

I have a dataframe like this one:

In [10]: df
Out[10]: 
         Column 1
foo              
Apples          1
Oranges         2
Puppies         3
Ducks           4

如何从该数据框中删除索引名称 foo
所需的输出如下:

How to remove index name foo from that dataframe? The desired output is like this:

In [10]: df
Out[10]: 
         Column 1             
Apples          1
Oranges         2
Puppies         3
Ducks           4


推荐答案

使用 del df.index.name

In [16]: df
Out[16]:
         Column 1
foo
Apples          1
Oranges         2
Puppies         3
Ducks           4

In [17]: del df.index.name

In [18]: df
Out[18]:
         Column 1
Apples          1
Oranges         2
Puppies         3
Ducks           4

这篇关于删除pandas中的索引名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆