- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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 - Return the right endpoints of each Interval in the IntervalArray as an Index
To return the right endpoints of each Interval in the IntervalArray as an Index, use the array.right property.
At first, import the required libraries −
import pandas as pd
Create two Interval objects −
interval1 = pd.Interval(10, 25) interval2 = pd.Interval(15, 70)
Display the intervals −
print("Interval1...\n",interval1) print("Interval2...\n",interval2)
Construct a new IntervalArray from Interval objects −
array = pd.arrays.IntervalArray([interval1,interval2])
Get the right endpoints −
print("\nThe right endpoints of each Interval in the IntervalArray as an Index...\n",array.right)
Example
Following is the code −
import pandas as pd # Create two Interval objects interval1 = pd.Interval(10, 25) interval2 = pd.Interval(15, 70) # display the intervals print("Interval1...\n",interval1) print("Interval2...\n",interval2) # Construct a new IntervalArray from Interval objects array = pd.arrays.IntervalArray([interval1,interval2]) # Display the IntervalArray print("\nOur IntervalArray...\n",array) # Getting the length of IntervalArray # Returns an Index with entries denoting the length of each Interval in the IntervalArray print("\nOur IntervalArray length...\n",array.length) # get the right endpoints print("\nThe right endpoints of each Interval in the IntervalArray as an Index...\n", array.right)
Output
This will produce the following code −
Interval1... (10, 25] Interval2... (15, 70] Our IntervalArray... <IntervalArray> [(10, 25], (15, 70]] Length: 2, dtype: interval[int64, right] Our IntervalArray length... Int64Index([15, 55], dtype='int64') The right endpoints of each Interval in the IntervalArray as an Index... Int64Index([25, 70], dtype='int64')
- Related Articles
- python Pandas - Return the left endpoints of each Interval in the IntervalArray as an Index
- Python Pandas - Return the midpoint of each Interval in the IntervalArray as an Index
- Python Pandas - Construct an IntervalArray from an array of splits and return the right endpoints of each interval
- Python Pandas - Construct an IntervalArray from an array-like of tuples and return the right endpoints of each Interval
- Python Pandas - Construct an IntervalArray from an array of splits and return the left endpoints of each interval
- Python Pandas - Return an Index with entries denoting the length of each Interval in the IntervalArray
- Python Pandas - Construct an IntervalArray from an array-like of tuples and return the left endpoints of each Interval
- Check elementwise if an Interval overlaps the values in the IntervalArray in Python Pandas
- Python Pandas - Create an open time interval and check for existence of both the endpoints
- Python Pandas - Return the midpoint of the Interval
- Python Pandas - Check elementwise if an Interval overlaps the values in the IntervalArray created from an array of splits
- Python Pandas IntervalArray - Check Intervals that share closed endpoints overlap or not
- Python Pandas - Return the Transpose of the index
- Python - Return an array representing the data in the Pandas Index
- Python Pandas - Check if the Pandas Index holds Interval objects

Advertisements