닫힌 끝점을 공유하는 간격이 겹치는지 확인하려면 IntervalArray.overlaps()를 사용하세요. Pandas의 메소드
먼저 필요한 라이브러리를 가져옵니다 -
import pandas as pd
닫힌 끝점을 포함하여 공통점을 공유하는 경우 두 간격이 겹칩니다. IntervalArray 생성
intervals = pd.arrays.IntervalArray.from_tuples([(10, 20), (15, 35)])
IntervalArray 표시 -
print("IntervalArray...\n",intervals)
닫힌 끝점을 공유하는 간격이 겹치는지 확인하십시오. "closed" 매개변수의 "left" 값으로 왼쪽에 closed를 설정했습니다 -
print("\nDoes interval that share closed endpoints overlap or not...\n",intervals.overlaps(pd.Interval(15,28, closed='left')))
예시
다음은 코드입니다 -
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), (15, 35)]) # Display the IntervalArray print("IntervalArray...\n",intervals) # Display the interval length print("\nInterval length...\n",intervals.length) # Check Intervals that share closed endpoints overlap or not # We have set closed on the left-side with the "left" value of the "closed" parameter print("\nDoes interval that share closed endpoints overlap or not...\n",intervals.overlaps(pd.Interval(15,28, closed='left')))
출력
이것은 다음과 같은 출력을 생성합니다 -
IntervalArray... <IntervalArray> [(10, 20], (15, 35]] Length: 2, dtype: interval[int64, right] Interval length... Int64Index([10, 20], dtype='int64') Does interval that share closed endpoints overlap or not... [ True True]