ComenzarEmpieza gratis

Monthly mean temperatures

After seeing the analysis of the average temperatures, you simply need to see the rest of the months. This would be rather annoying to do using the method we used before as it involves a lot of complicated slicing in time to select the right months. Thankfully, with Xarray, it is a lot simpler.

The European weather dataset is available in your environment as the Xarray DataSet ds.

Este ejercicio forma parte del curso

Parallel Programming with Dask in Python

Ver curso

Instrucciones del ejercicio

  • Use the datetime accessor in the 'time' coordinate of ds to assign the months to the variable months.
  • Select the 'temp' variable from ds and group it by the months.
  • Take the mean over the group to calculate the monthly means over all times.
  • Compute the result.

Ejercicio interactivo práctico

Prueba este ejercicio y completa el código de muestra.

# 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()
Editar y ejecutar código