Aan de slagGa gratis aan de slag

Marketing channels across age groups

Some marketing stakeholders want to know if their marketing channels are reaching all users equally or if some marketing channels are serving specific age demographics.

Within a marketing team, it is common to get requests that require quick analysis and visualization. The better you are at visualizing the results, the more likely that you will effectively communicate your findings to your stakeholders.

In this exercise, you will create a grouped bar chart showing how many people each marketing channel reached by age group.

Deze oefening maakt deel uit van de cursus

Analyzing Marketing Campaigns with pandas

Cursus bekijken

Oefeninstructies

  • Unstack channel_age with level = 1 and transform the result into a DataFrame.
  • Plot channel_age as a grouped bar chart.
  • Add a legend in the upper right and set the labels equal to channel_age_df.columns.values.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

channel_age = marketing.groupby(['marketing_channel', 'age_group'])\
                                ['user_id'].count()

# Unstack channel_age and transform it into a DataFrame
channel_age_df = ____.____(channel_age.____(____ = ____))

# Plot channel_age
____.____(____ = '____')
plt.title('Marketing channels by age group')
plt.xlabel('Age Group')
plt.ylabel('Users')
# Add a legend to the plot
____.____(____ = '____', 
           ____ = ____)
plt.show()
Code bewerken en uitvoeren