보간 결과 그리기
여러 보간 결과를 비교해 그래프로 그려 보면, 어떤 기법이 가장 적합한지 판단하는 데 큰 도움이 됩니다. 이 연습 문제에서는 여러 보간 기법에 대한 플롯을 생성하기 위해 for 반복문을 만듭니다. 직전 레슨에서 수행한 선형(linear), 2차(quadratic), 최근접(nearest) 보간 기법의 결과를 각각 시각화해 보세요.
보간 기법 이름을 따서 만든 세 개의 DataFrame linear_interp, quadratic_interp, nearest_interp가 이미 준비되어 있습니다.
이 연습은 강의의 일부입니다
Python에서 결측치 다루기
연습 안내
- 각 보간 기법마다 서브플롯 3개를 만드세요.
linear_interp,quadratic_interp,nearest_interpDataFrame을 해당 보간 기법에 매핑해interpolations딕셔너리를 만드세요.axes와interpolations을 함께 순회(loop)하세요.interpolations에서 각 DataFrame을 선택하고,df_key를 사용해 해당 DataFrame의 제목을 설정하세요.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
# Set nrows to 3 and ncols to 1
fig, axes = plt.subplots(___, ___, figsize=(30, 20))
# Create a dictionary of interpolated DataFrames for looping
interpolations = {'Linear Interpolation': ___, 'Quadratic Interpolation': ___,
'Nearest Interpolation': ___}
# Loop over axes and interpolations
for ax, df_key in zip(___, ___):
# Select and also set the title for a DataFrame
interpolations[___].Ozone.plot(color='red', marker='o', linestyle='dotted', ax=ax)
airquality.Ozone.plot(title=___ + ' - Ozone', marker='o', ax=ax)
plt.show()