Interval이 왼쪽에서 닫혀 있는지 확인하려면 interval.closed_right를 사용하세요. 특성. 먼저 필요한 라이브러리를 가져옵니다 -
import pandas as pd
값이 "right"인 "closed" 매개변수를 사용하여 설정된 간격, 즉 [0, 5)는 closed='right'
일 때 0간격 표시
print("Interval...\n",interval) 오른쪽에서 간격이 닫혀 있는지 확인하십시오.
print("\nChecking whether the Interval is closed on the right...\n", interval.closed_right)
예시
다음은 코드입니다.
import pandas as pd
# Interval set using the "closed" parameter with value "right"
# i.e. [0, 5) is described by 0 < x <= 5 when closed='right'
interval = pd.Interval(left=0, right=20, closed='right')
# display the interval
print("Interval...\n",interval)
# display the interval length
print("\nInterval length...\n",interval.length)
# check whether the interval is closed on the right-side
print("\nChecking whether the Interval is closed on the right...\n", interval.closed_right)
# check for the existence of an element in an Interval
# This shows that closed = right contain only the right-most endpoint
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] Interval length... 20 Checking whether the Interval is closed on the right... True