 
 Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Python Pandas - Create RangeIndex from a range object
To create RangeIndex from a range object, use the pd.RangeIndex.from_range(range()) method in Pandas.
At first, import the required libraries −
import pandas as pd
Create RangeIndex −
index = pd.RangeIndex.from_range(range(10, 30))
Display the RangeIndex −
print("RangeIndex...\n",index)
Example
Following is the code −
import pandas as pd
# RangeIndex
index = pd.RangeIndex.from_range(range(10, 30))
# Display the RangeIndex
print("RangeIndex...\n",index)
# Display the start value
print("\nRangeIndex start value...\n",index.start)
# Display the end value
print("\nRangeIndex end value...\n",index.stop)
Output
This will produce the following output −
RangeIndex... RangeIndex(start=10, stop=30, step=1) RangeIndex start value... 10 RangeIndex end value... 30
Advertisements
                    