1. Learn
  2. /
  3. Courses
  4. /
  5. Machine Learning for Marketing in Python

Connected

Exercise

Understand differences in variables

Now, you will analyze the averages and standard deviations of each variable by plotting them in a barplot. This is a complementary step to the one before, as you will visually explore the differences in variable scales and variances.

The pandas library is loaded as pd and matplotlib.pyplot as plt. Also, the wholesale dataset has been loaded as a pandas DataFrame, while the averages and standard deviations for each column of the wholesale dataset are loaded as pandas Series named averages and std_devs respectively. Make sure you explore them in the console.

Instructions

100 XP
  • Create a list with wholesale's column names and another one with sorted values from 0 to the number of columns in wholesale.
  • Plot averages in grey and std_devs in orange, adjust the x-axis by 0.2
  • Add x_ix as ticks and x_names as labels and make sure you rotate them by 90 degrees.
  • Add the legend and display the chart.