Pandas Series.index
Pandas Series.index property
In this tutorial, we'll go through examples for the Pandas Series.index property, which returns the index (labels) of a Pandas Series.
The index provides a way to uniquely label each element in the Series.
Examples for Series index property
1. Getting index of the given Series
In the following program, we take a Series object in series_data, get its index, and print the index to output.
Python Program
import pandas as pd
# Create a Pandas Series
series_data = pd.Series([10, 20, 30, 40, 50])
# Access Series index
series_index = series_data.index
# Display the Series index
print("Series Index")
print(series_index)Output
Series Index
RangeIndex(start=0, stop=5, step=1)To get the index as a list, you can use Index.to_list() as shown in the following.
Python Program
import pandas as pd
# Create a Pandas Series
series_data = pd.Series([10, 20, 30, 40, 50])
# Access Series index
series_index = series_data.index
# Display the Series index
print("Series Index")
print(series_index.to_list())Output
Series Index
[0, 1, 2, 3, 4]