월별 평균 기온
평균 기온을 분석해 본 뒤, 이제는 나머지 달도 확인해 보려고 합니다. 이전에 사용한 방법으로는 올바른 달을 선택하기 위해 시간에서 복잡한 슬라이싱을 많이 해야 해서 꽤 번거롭습니다. 다행히 Xarray를 사용하면 훨씬 간단해요.
유럽 날씨 데이터셋은 Xarray DataSet ds로 환경에 준비되어 있습니다.
이 연습은 강의의 일부입니다
Python에서 Dask로 병렬 프로그래밍
연습 안내
ds의'time'좌표에서 datetime 접근자(Accessor)를 사용해 월 정보를 변수months에 할당하세요.ds에서'temp'변수를 선택하고 이를months로 그룹화하세요.- 모든 시간에 대해 월별 평균을 계산하도록 그룹의 평균을 구하세요.
- 결과를 계산하세요.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
# Extract the months from the time coordinates
months = ds['____'].____.____
# Select the temp DataArray and group by months
monthly_groupby = ds['____'].____(____)
# Find the mean temp by month
monthly_mean_temps = ____.____()
# Compute the result
monthly_mean_temps_computed = ____.____()
monthly_mean_temps_computed.plot(col='month', col_wrap=4, add_colorbar=False)
plt.show()