Skip to main content

Python Pandas Objects: Index.names

Pandas Series can have a name and these are set as columns names in dataframe. The index can also have its own name, these names are known as index names.

Example

import pandas as pd

books_names=['Don Quixote','Lord of the Rings','Pinocchio','And Then There Were None']
books_series=pd.Series(books_names)#series
books_series.name="Famous Books"#index name

print(books_series)

Output:

0                 Don Quixote
1           Lord of the Rings
2                   Pinocchio
3    And Then There Were None
Name: Famous Books, dtype: object

Here in the above example "Famous Books" is the index name. 

Submitted by devanshi.srivastava on November 2, 2021

Devanshi, is working as a Data Scientist with iVagus. She has expertise in Python, NumPy, Pandas and other data science technologies.

About

At ProgramsBuzz, you can learn, share and grow with millions of techie around the world from different domain like Data Science, Software Development, QA and Digital Marketing. You can ask doubt and get the answer for your queries from our experts.