DataFrame 준비하기
이 연습 문제에서는 교통 단속과 날씨 등급 DataFrame을 병합할 수 있도록 준비해 보겠습니다.
riDataFrame에서는 병합 과정에서 인덱스가 사라지므로stop_datetime인덱스를 열로 이동합니다.weatherDataFrame에서는DATE와rating열만 선택해 새 DataFrame으로 만듭니다.
이 연습은 강의의 일부입니다
pandas로 경찰 활동 분석하기
연습 안내
riDataFrame의 인덱스를 재설정하세요.ri의 head를 확인해stop_datetime이 이제 DataFrame 열이 되었고, 인덱스가 기본 정수 인덱스로 바뀌었는지 확인하세요.weatherDataFrame에서DATE와rating열만 포함하는weather_rating이라는 새 DataFrame을 만드세요.weather_rating의 head를 확인해 필요한 열이 들어 있는지 검증하세요.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
# Reset the index of 'ri'
# Examine the head of 'ri'
print(____)
# Create a DataFrame from the 'DATE' and 'rating' columns
# Examine the head of 'weather_rating'
print(____)