- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- 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