यह जांचने के लिए कि बाईं ओर कोई अंतराल बंद है या नहीं, अंतराल.बंद_दाएं . का उपयोग करें संपत्ति। सबसे पहले, आवश्यक पुस्तकालयों को आयात करें -
import pandas as pd
"दाएं" मान वाले "बंद" पैरामीटर का उपयोग करके अंतराल सेट अर्थात [0, 5) का वर्णन 0
interval = pd.Interval(left=0, right=20, closed='right')
अंतराल प्रदर्शित करें
print("Interval...\n",interval)
जांचें कि क्या अंतराल दाईं ओर बंद है
print("\nChecking whether the Interval is closed on the right...\n", interval.closed_right)
उदाहरण
निम्नलिखित कोड है
import pandas as pd # Interval set using the "closed" parameter with value "right" # i.e. [0, 5) is described by 0 < x <= 5 when closed='right' interval = pd.Interval(left=0, right=20, closed='right') # 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 right-side print("\nChecking whether the Interval is closed on the right...\n", interval.closed_right) # check for the existence of an element in an Interval # This shows that closed = right contain only the right-most endpoint print("\nThe left-most element exists in the Interval? = \n",0 in interval) print("\nThe right-most element exists in the Interval? = \n",20 in interval)
आउटपुट
यह निम्नलिखित कोड उत्पन्न करेगा
Interval... (0, 20] Interval length... 20 Checking whether the Interval is closed on the right... True