LernerPython 블로그, Reuven Lerne... 노트

LernerPython 블로그, Reuven Lerner 제공: Pandas 날짜 범위 선택: .loc를 사용한 datetime 인덱스 슬라이싱

Python Pandas 데이터 프레임에서 특정 시간 구간을 선택하고 싶으신가요?datetime 열을 인덱스로 설정한 후, .loc와 슬라이스를 사용하여 날짜를 선택하세요:( df .set_index('tpep_pickup_datetime') .sort_index() .loc['2025-11-10':'2025-11-20'] ['trip_distance'] .mean() )
CdXz5zHNQW_m7T8KjdrIO.png