Remove index name in pandas

pandas reset_index name
remove index pandas
remove column name pandas
pandas drop column
rename index pandas
pandas reset index
pandas set index
reorder index pandas

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

Use 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 - remove the label of the column index, Simply delete the name of the columns: del df.columns.name. Also, note that df.​index.names = [''] is not quite the same as del df.index.name . pandas.Index.rename¶ Index.rename (self, name, inplace=False) [source] ¶ Alter Index or MultiIndex name. Able to set new names without level. Defaults to returning new index. Length of names must match number of levels in MultiIndex. Parameters name label or list of labels. Name(s) to set. inplace bool, default False

Alternatively you can just assign None to the index.name attribute:

In [125]:

df.index.name = None
df
Out[125]:
         Column 1

Apples          1
Oranges         2
Puppies         3
Ducks           4

Remove index name in pandas, 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  Remove index name in pandas ; Remove index name in pandas. 0 votes . 1 view. asked Aug 31, 2019 in Data Science by sourav (17.6k points) I have a dataframe like this

From version 0.18.0 you can use rename_axis:

print df
         Column 1
foo              
Apples          1
Oranges         2
Puppies         3
Ducks           4

print df.index.name
foo


print df.rename_axis(None)
         Column 1
Apples          1
Oranges         2
Puppies         3
Ducks           4

print df.rename_axis(None).index.name
None

# To modify the DataFrame itself:
df.rename_axis(None, inplace=True)
print df.index.name
None

pandas.Index.drop, Index.name · pandas.Index.names · pandas.Index.nbytes · pandas. Index.drop​¶. Index. drop (labels, errors='raise')[source]¶. Make new Index with passed list  nutrition_info_256174499 = df1.loc[:"Salt" , "%Reference Intake*"] print (nutrition_info_256174499) Typical Values Energy 5% Fat 1% of which saturates 1% Carbohydrates 7% of which sugars 2% Fibre - Protein 7% Salt 6% Name: %Reference Intake*, dtype: object.

pandas.DataFrame.reset_index, If the DataFrame has a MultiIndex, this method can remove one or more levels. Parameters dropbool, default False If None then the index name is repeated. With pandas’ rename function, one can also change both column names and row names simultaneously by using both column and index arguments to rename function with corresponding mapper dictionaries. Let us change the column name “lifeExp” to “life_exp” and also row indices “0 & 1” to “zero and one”.

pandas.DataFrame.drop, Remove rows or columns by specifying label names and corresponding axis, or by specifying directly index or column names. When using a multi-index, labels  Python Pandas : Replace or change Column & Row index names in DataFrame; Pandas : How to create an empty DataFrame and append rows & columns to it in python; Pandas : count rows in a dataframe | all or those only that satisfy a condition; Pandas : Convert Dataframe column into an index using set_index() in Python

pandas.Index.drop, Index.name · pandas.Index.names · pandas.Index.nbytes · pandas.Index.ndim Index.delete; pandas.Index.drop; pandas.Index.drop_duplicates · pandas. pandas.DataFrame.reset_index¶. Reset the index, or a level of it. Reset the index of the DataFrame, and use the default one instead. If the DataFrame has a MultiIndex, this method can remove one or more levels. Only remove the given levels from the index. Removes all levels by default. Do not try to insert index into dataframe columns.