LernerPython 블로그, Reuven Lerner 제공: Pandas DatetimeIndex 슬라이싱: sort_index로 KeyError 수정
Python Pandas에서 정렬되지 않은 datetime 인덱스를 슬라이싱하면 다음과 같은 오류가 발생할 가능성이 높습니다.KeyError: ‘Value based partial slicing on non-monotonic DatetimeIndexes with non-existing keys is not allowed.’왜 그럴까요? 날짜가 정렬되지 않았다면 Pandas는 어디서 시작하고 어디서 멈춰야 할까요?해결책: sort_index!