यह जांचने के लिए कि बाईं ओर कोई अंतराल बंद है या नहीं, interval.closed_left संपत्ति का उपयोग करें . सबसे पहले, आवश्यक पुस्तकालयों को आयात करें -
import pandas as pd
"बाएं" मान के साथ "बंद" पैरामीटर का उपयोग करके अंतराल सेट अर्थात [0, 5) का वर्णन 0 <=x <5 द्वारा किया जाता है जब बंद ='बाएं'
interval = pd.Interval(left=0, right=20, closed='left')
अंतराल प्रदर्शित करें
print("Interval...\n",interval) जांचें कि क्या अंतराल बाईं ओर बंद है
print("\nChecking whether the Interval is closed on the left...\n", interval.closed_left)
उदाहरण
निम्नलिखित कोड है
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) आउटपुट
यह निम्नलिखित कोड उत्पन्न करेगा
Interval... [0, 20) Interval length... 20 Checking whether the Interval is closed on the left... True