공통 오버랩에서 열린 끝점만 있는 Interval을 확인하려면 overlaps()를 사용하세요. 방법.
먼저 필요한 라이브러리를 가져옵니다 -
import pandas as pd
닫힌 끝점을 포함하여 공통점을 공유하는 경우 두 간격이 겹칩니다. IntervalArray 생성 -
intervals = pd.arrays.IntervalArray.from_tuples([(10, 20), (20, 35)])
IntervalArray 표시 -
print("IntervalArray...\n",intervals)
공통 겹침에서 열린 끝점만 있는 간격을 확인합니다. "closed" 매개변수의 "right" 값으로 오른쪽에 closed를 설정했습니다 -
print("\nDoes interval that that only have an open endpoint overlap or not...\n",intervals.overlaps(pd.Interval(20,25, closed='right')))
예시
다음은 코드입니다 -
import pandas as pd # Two intervals overlap if they share a common point, including closed endpoints # Create an IntervalArray intervals = pd.arrays.IntervalArray.from_tuples([(10, 20), (20, 35)]) # Display the IntervalArray print("IntervalArray...\n",intervals) # Display the interval length print("\nInterval length...\n",intervals.length) # Check Intervals that only have an open endpoint in common overlap or not # We have set closed on the right-side with the "right" value of the "closed" parameter print("\nDoes interval that that only have an open endpoint overlap or not...\n",intervals.overlaps(pd.Interval(20,25, closed='right')))
출력
이것은 다음과 같은 출력을 생성합니다 -
IntervalArray... <IntervalArray> [(10, 20], (20, 35]] Length: 2, dtype: interval[int64, right] Interval length... Int64Index([10, 15], dtype='int64') Does interval that that only have an open endpoint overlap or not... [False True]