Plot interpolations
Plotting comparative graphs for the imputations is essential for inferring the best imputation technique. In this exercise, you'll create a for loop for generating plots for multiple imputation techniques. You will create the plots of the imputations you performed in the previous lesson i.e., the linear, the quadratic, and the nearest interpolation techniques.
Three DataFrames named after their imputation techniques have already been imported for you, namely, linear_interp
, quadratic_interp
, and nearest_interp
Este exercício faz parte do curso
Dealing with Missing Data in Python
Instruções do exercício
- Create 3 subplots for each imputation technique.
- Create the
interpolations
dictionary by mapping thelinear_interp
,quadratic_interp
, andnearest_interp
DataFrames to the relevant interpolation technique. - Loop over
axes
andinterpolations
. - Select each DataFrame in
interpolations
and set the title for a DataFrame usingdf_key
.
Exercício interativo prático
Experimente este exercício completando este código de exemplo.
# 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()