간격이 왼쪽, 오른쪽, 둘 다 또는 둘 다에서 닫혀 있는지 확인하려면 interval.closed 속성을 사용하세요.
먼저 필요한 라이브러리를 가져옵니다 -
import pandas as pd
값이 "both"인 "closed" 매개변수를 사용하여 설정된 닫힌 간격입니다. 닫힌 구간(수학에서 대괄호로 표시됨)은 끝점을 포함합니다. # 즉, 닫힌 구간 [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