इंटरवल का बाईं ओर खुला होना जाँचें
Pandas में interval.open_left प्रॉपर्टी का उपयोग करके यह जाँचा जा सकता है कि इंटरवल बाईं ओर खुला है या नहीं।
आवश्यक लाइब्रेरी आयात करें
import pandas as pd
खुला इंटरवल बनाएँ
interval = pd.Interval(5, 20, closed='neither')
इंटरवल प्रदर्शित करें
print("Interval...\n", interval)
बाईं ओर खुला है या नहीं जाँचें
print("\nCheck if the interval is open on the left side...\n", interval.open_left)
पूर्ण उदाहरण
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 left side...\n", interval.open_left)
आउटपुट
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 left side... True
व्याख्या
closed='neither'से इंटरवल(5, 20)बनता हैopen_leftTrueलौटाता है क्योंकि बायाँ एंडपॉइंट 5 शामिल नहीं हैopen_rightभीTrueहोगा- गणितीय नोटेशन:
(a, b)={x | a < x < b}
क्लोजर प्रकार और open_left/open_right मान
| closed | नोटेशन | open_left | open_right |
|---|---|---|---|
'both' | [a, b] | False | False |
'left' | [a, b) | False | True |
'right' | (a, b] | True | False |
'neither' | (a, b) | True | True |