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