
- 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 - Check if an Interval is closed on the left side
To check if an Interval is closed on the left side, use the interval.closed_left property. At first, import the required libraries −
import pandas as pd
Interval set using the "closed" parameter with value "left" i.e. [0, 5) is described by 0 <= x < 5 when closed='left'
interval = pd.Interval(left=0, right=20, closed='left')
Display the interval
print("Interval...\n",interval)
Check whether the interval is closed on the left-side
print("\nChecking whether the Interval is closed on the left...\n", interval.closed_left)
Example
Following is the code
import pandas as pd # Interval set using the "closed" parameter with value "left" # i.e. [0, 5) is described by 0 <= x < 5 when closed='left' interval = pd.Interval(left=0, right=20, closed='left') # display the interval print("Interval...\n",interval) # display the interval length print("\nInterval length...\n",interval.length) # check whether the interval is closed on the left-side print("\nChecking whether the Interval is closed on the left...\n", interval.closed_left)
Output
This will produce the following code
Interval... [0, 20) Interval length... 20 Checking whether the Interval is closed on the left... True
- Related Articles
- Python Pandas - Check if an interval is empty if closed from the left side
- Python Pandas - Check if an Interval is closed on the right side
- Python Pandas - Check whether the interval is closed on the left-side, right-side, both or neither
- Python Pandas - Check if the interval is open on the left side
- Python Pandas - Check if an interval is empty if closed from the both sides
- Python Pandas - Check if the interval is open on the right side
- Python Pandas - Check whether the IntervalIndex intervals are closed on the left-side, right-side, both or neither
- Python Pandas - Check if an interval is empty
- Python Pandas - Check whether the intervals in IntervalArray are closed on the left-side, right-side, both or neither
- Python Pandas - Return an IntervalArray identical to the current one but closed on the left side
- Python Pandas - Check if an element belongs to an Interval
- Python Pandas - Check if an interval set as open is empty
- Python Pandas - Create an IntervalArray from an array of splits and check the intervals are closed on the left or right-side, both or neither
- Python Pandas - Check if the Pandas Index holds Interval objects
- Python Pandas - Check whether two Interval objects that share closed endpoints overlap

Advertisements