কম্পিউটার

পাইথন পান্ডাস - ব্যবধানটি বাম-পাশে, ডান-পাশে, উভয় বা উভয়ই বন্ধ আছে কিনা তা পরীক্ষা করুন


ব্যবধানটি বাম-পাশে, ডান-পাশে, উভয় বা উভয়ই বন্ধ আছে কিনা তা পরীক্ষা করতে, interval.closed প্রপার্টি ব্যবহার করুন।

প্রথমে, প্রয়োজনীয় লাইব্রেরিগুলি আমদানি করুন -

import pandas as pd

"উভয়" মান সহ "বন্ধ" প্যারামিটার ব্যবহার করে ক্লোজড ব্যবধান সেট করা হয়েছে। একটি বদ্ধ ব্যবধান (বর্গ বন্ধনী দ্বারা চিহ্নিত গণিতে) এর শেষ বিন্দু রয়েছে, # অর্থাৎ বদ্ধ ব্যবধান [0, 5] শর্তাবলী দ্বারা চিহ্নিত করা হয় 0 <=x <=5

interval = pd.Interval(left=0, right=20, closed='both')

ব্যবধান প্রদর্শন করুন

print("Interval...\n",interval)

ব্যবধানটি বাম-পাশে, ডান-পাশে, উভয় বা উভয়ই বন্ধ আছে কিনা তা পরীক্ষা করুন

print("\nChecking for the type of Interval...\n",interval.closed)

উদাহরণ

নিম্নলিখিত কোড

import pandas as pd

# Closed interval set using the "closed" parameter with value "both"
# A closed interval (in mathematics denoted by square brackets) contains its endpoints,
# i.e. the closed interval [0, 5] is characterized by the conditions 0 <= x <= 5.
interval = pd.Interval(left=0, right=20, closed='both')

# display the interval
print("Interval...\n",interval)

# check whether the interval is closed on the left-side, right-side, both or neither
print("\nChecking for the type of Interval...\n",interval.closed)

# check for the existence of an element in an Interval
# This shows that closed = both contains its endpoints
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]

Checking for the type of Interval...
both


  1. Python Pandas - পিরিয়ড অবজেক্ট থেকে বছরটি একটি লিপ ইয়ার কিনা তা পরীক্ষা করুন

  2. Python Pandas - বিভক্তের একটি অ্যারে থেকে একটি IntervalArray তৈরি করুন এবং বাম বা ডান-পাশে, উভয় বা উভয়ই বন্ধ আছে কিনা তা পরীক্ষা করুন

  3. Python Pandas - পান্ডাস সূচক ইন্টারভাল অবজেক্ট ধারণ করে কিনা তা পরীক্ষা করুন

  4. Python Pandas - IntervalArray-এর মধ্যে বিরতিগুলি বাম-পাশে, ডান-পাশে, উভয় বা উভয়ই বন্ধ আছে কিনা তা পরীক্ষা করুন