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. 

Tue, 11/02/2021 - 21:12

Authored by

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