Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Data Science by (17.6k points)

I have a dataframe like this one:

In [10]: df

Out[10]: 

         Column 1

foo              

Apples          1

Oranges         2

Puppies         3

Ducks           4

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

1 Answer

0 votes
by (41.4k points)

Use del df.index.name:

In [26]: df

Out[26]:

         Column 1

foo

Apples          1

Oranges         2

Puppies         3

Ducks           4

In [27]: del df.index.name

In [28]: df

Output:

          Column 1

Apples          1

Oranges         2

Puppies         3

Ducks           4

If you want to learn more about Pandas then visit this Python Tutorial.

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...