
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
Python Pandas - Get the right bound for the interval
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
- Related Articles
- Python Pandas - Get the left bound for the interval
- Python Pandas - Get the right bound for the IntervalIndex
- Python Pandas - Get the left bound for the IntervalIndex
- Python Pandas - Get the length of the Interval
- Python Pandas - Calculate the right slice bound that corresponds to given label
- Python Pandas - Check if the interval is open on the right side
- Python Pandas - Check if an Interval is closed on the right side
- Python Pandas - Return the right endpoints of each Interval in the IntervalArray as an Index
- Python - Create a Pandas array for interval data
- Python Pandas - Return the midpoint of the Interval
- Python Pandas - Check if the Pandas Index holds Interval objects
- Python Pandas - Check whether the interval is closed on the left-side, right-side, both or neither
- Python Pandas - Calculate the left slice bound that corresponds to given label
- Python Pandas - Get the frequency for the given Period object
- Python Pandas IntervalIndex - Get the locations of all the relevant interval if a label is in several intervals

Advertisements