अंतराल की लंबाई प्राप्त करने के लिए, अंतराल.लंबाई . का उपयोग करें संपत्ति। सबसे पहले, आवश्यक पुस्तकालयों को आयात करें -
import pandas as pd
"न तो" मान के साथ "बंद" पैरामीटर का उपयोग करके खुला अंतराल सेट करें। एक खुला अंतराल (गणित में वर्ग कोष्ठक द्वारा दर्शाया गया है) में इसके समापन बिंदु नहीं होते हैं, अर्थात खुला अंतराल [0, 5] शर्तों की विशेषता है 0
interval = pd.Interval(5, 20, closed='neither')
अंतराल की लंबाई प्रदर्शित करें
print("\nInterval length...\n",interval.length)
उदाहरण
निम्नलिखित कोड है
import pandas as pd # Open interval set using the "closed" parameter with value "neither" # An open interval (in mathematics denoted by square brackets) does not contains its endpoints, # i.e. the open interval [0, 5] is characterized by the conditions 0 < x < 5. interval = pd.Interval(5, 20, closed='neither') # display the interval print("Interval...\n",interval) # the left bound print("\nThe left bound for the Interval...\n",interval.left) # the right bound print("\nThe right bound for the Interval...\n",interval.right) # display the interval length print("\nInterval length...\n",interval.length)
आउटपुट
यह निम्नलिखित कोड उत्पन्न करेगा
Interval... (5, 20) The left bound for the Interval... 5 The right bound for the Interval... 20 Interval length... 15