
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
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
Get the Right Bound for the Interval in Python Pandas
To get the right bound for the interval, use the interval.right property. At first, import the required libraries −
import pandas as pd
Use Timestamps as the bounds to create a time interval. Closed interval set using the "closed" parameter with value "right" −
interval = pd.Interval(pd.Timestamp('2020-01-01 00:00:00'), pd.Timestamp('2021-01-01 00:00:00'), closed='left')
Get the right bound −
print("\nThe right bound for the Interval...\n",interval.right)
Example
Following is the code −
import pandas as pd # Use Timestamps as the bounds to create a time interval # Closed interval set using the "closed" parameter with value "right" interval = pd.Interval(pd.Timestamp('2020-01-01 00:00:00'), pd.Timestamp('2021-01-01 00:00:00'), closed='left') # display the interval print("Interval...\n",interval) # display the interval length print("\nInterval length...\n",interval.length) # get the right bound print("\nThe right bound for the Interval...\n",interval.right)
Output
This will produce the following code −
Interval... [2020-01-01, 2021-01-01) Interval length... 366 days 00:00:00 The right bound for the Interval... 2021-01-01 00:00:00
Advertisements