इंटरवल का दाईं ओर खुला होना जाँचें
Pandas में interval.open_right प्रॉपर्टी का उपयोग करके यह जाँचा जा सकता है कि इंटरवल दाईं ओर खुला है या नहीं।
आवश्यक लाइब्रेरी आयात करें
import pandas as pd
खुला इंटरवल बनाएँ
closed='neither' से दोनों तरफ खुला इंटरवल बनता है:
interval = pd.Interval(5, 20, closed='neither')
इंटरवल प्रदर्शित करें
print("Interval...\n", interval)
दाईं ओर खुला है या नहीं जाँचें
print("\nCheck if the interval is open on the right side...\n", interval.open_right)
पूर्ण उदाहरण
import pandas as pd
# खुला इंटरवल closed='neither' से बनता है
# खुला इंटरवल (गणित में वर्ग कोष्ठक से दर्शाया जाता है) अपने एंडपॉइंट्स नहीं रखता
# अर्थात खुला इंटरवल [0, 5] की शर्तें 0 < x < 5 हैं
interval = pd.Interval(5, 20, closed='neither')
# इंटरवल प्रदर्शित करें
print("Interval...\n", interval)
# बायाँ बाउंड
print("\nThe left bound for the Interval...\n", interval.left)
# दायाँ बाउंड
print("\nThe right bound for the Interval...\n", interval.right)
# इंटरवल लंबाई
print("\nInterval length...\n", interval.length)
# दाईं ओर खुला है या नहीं जाँचें
print("\nCheck if the interval is open on the right side...\n", interval.open_right)
आउटपुट
Interval...
(5, 20)
The left bound for the Interval... 5
The right bound for the Interval... 20
Interval length... 15
Check if the interval is open on the right side... True
व्याख्या
closed='neither'से इंटरवल(5, 20)बनता है (दोनों तरफ खुला)open_rightTrueलौटाता है क्योंकि दायाँ एंडपॉइंट 20 शामिल नहीं हैopen_leftभीTrueहोगा क्योंकि बायाँ एंडपॉइंट 5 भी शामिल नहीं है- लंबाई = 20 - 5 = 15 (एंडपॉइंट्स शामिल नहीं)
संबंधित प्रॉपर्टीज
| प्रॉपर्टी | विवरण |
|---|---|
open_left | बायाँ एंडपॉइंट खुला है? |
open_right | दायाँ एंडपॉइंट खुला है? |
closed | क्लोजर प्रकार लौटाता है |
left | बायाँ बाउंड मान |
right | दायाँ बाउंड मान |