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. RangeIndex is a memory-efficient special case of Int64Index that represents monotonic ranges without storing all values in memory.

What is RangeIndex?

RangeIndex is optimized for representing evenly spaced integer sequences. It stores only the start, stop, and step values rather than all individual index values, making it memory-efficient for large ranges.

Creating a RangeIndex

First, let's create a RangeIndex with specific parameters ?

import pandas as pd

# Create a RangeIndex with start=10, stop=30, step=2
index = pd.RangeIndex(start=10, stop=30, step=2, name="data")
print("RangeIndex:")
print(index)
RangeIndex:
RangeIndex(start=10, stop=30, step=2, name='data')

Accessing the Step Parameter

Use the step property to retrieve the step value ?

import pandas as pd

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

# Display all parameters
print("Start value:", index.start)
print("Stop value:", index.stop)
print("Step value:", index.step)
print("Name:", index.name)
Start value: 10
Stop value: 30
Step value: 2
Name: data

RangeIndex Properties Summary

Property Description Example Value
index.start Starting value of the range 10
index.stop Stopping value (exclusive) 30
index.step Step size between values 2
index.name Name assigned to the index "data"

Viewing the Actual Values

To see the actual sequence values generated by the RangeIndex ?

import pandas as pd

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

print("Step value:", index.step)
print("Actual sequence values:")
print(list(index))
Step value: 2
Actual sequence values:
[10, 12, 14, 16, 18, 20, 22, 24, 26, 28]

Conclusion

The index.step property retrieves the step parameter from a RangeIndex. RangeIndex is memory-efficient for large sequential data as it stores only start, stop, and step values rather than all individual elements.

Updated on: 2026-03-26T16:42:01+05:30

347 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements