- 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 - Get the right bound for the IntervalIndex
To get the right bound for the IntervalIndex, use the interval.right property in Pandas. At first, import the required libraries −
import pandas as pd
Create IntervalIndex −
interval = pd.IntervalIndex.from_arrays([5, 10, 15], [15, 20, 25])
Display the interval −
print("IntervalIndex...\n",interval)
Get the right bound −
print("\nThe right bound for the IntervalIndex...\n",interval.right)
Example
Following is the code −
import pandas as pd # Create IntervalIndex interval = pd.IntervalIndex.from_arrays([5, 10, 15], [15, 20, 25]) # Display the interval print("IntervalIndex...\n",interval) # Display the interval length print("\nIntervalIndex length...\n",interval.length) # Check whether the IntervalIndex is closed on the left-side, right-side, both or neither print("\nChecking for the type of IntervalIndex...\n",interval.closed) # Get the right bound print("\nThe right bound for the IntervalIndex...\n",interval.right)
Output
This will produce the following output −
IntervalIndex... IntervalIndex([(5, 15], (10, 20], (15, 25]], dtype='interval[int64, right]') IntervalIndex length... Int64Index([10, 10, 10], dtype='int64') Checking for the type of IntervalIndex... right The right bound for the IntervalIndex... Int64Index([15, 20, 25], dtype='int64')
Advertisements