Python Pandas - Display the value of the step parameter of RangeIndex



To display the value of the step parameter of RangeIndex, use the index.step property in Pandas.

At first, import the required libraries −

import pandas as pd

RangeIndex is a memory-saving special case of Int64Index limited to representing monotonic ranges. Create a range index with start, stop and step. The name is the name to be stored in the index.

index = pd.RangeIndex(start=10, stop=30, step=2, name="data")

Display the step parameter value −

print("\nRangeIndex step value...\n",index.step)

Example

Following is the code −

Open Compiler
import pandas as pd # RangeIndex is a memory-saving special case of Int64Index limited to representing monotonic ranges. # Create a range index with start, stop and step # The name is the name to be stored in the index. index = pd.RangeIndex(start=10, stop=30, step=2, name="data") # Display the RangeIndex print("RangeIndex...\n",index) # Display the start parameter value print("\nRangeIndex start value...\n",index.start) # Display the step parameter value print("\nRangeIndex step value...\n",index.step)

Output

This will produce the following output −

RangeIndex...
RangeIndex(start=10, stop=30, step=2, name='data')

RangeIndex start value...
10

RangeIndex step value...
2
Updated on: 2021-10-14T11:05:37+05:30

270 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements