Example of Matplotilb assisting data preprocessing
A great way to get to know a new dataset is to visualize its columns. The numerical columns are best visualized using either histograms or boxplots. However, the combination of the two is the best, especially when the boxplot is drawn vertically. Use the subplot function of Matplotlib to draw the histogram and boxplot of all the numerical columns of adult_df in a 2x5 matrix-like visual. Make sure that the histogram and the boxplot of each column are in the same subplot column. Also, save the visual in a file named ColumnsVsiaulization.png
with a resolution of 900
DPI.
The following code shows the solution for this example:
Numerical_colums = ['age', 'education_num', 'capitalGain', 'capitalLoss', 'hoursPerWeek'] plt.figure(figsize=(20,5)) for i,col in enumerate(Numerical_colums): Â Â Â Â plt.subplot(2,5,i+1) Â Â Â Â plt.hist(adult_df[col]) Â ...