Aan de slagGa gratis aan de slag

Test and visualize conversion function

You've done the hard work of building your conversion rate function—now it's time to test it out! Automating your analyses can be time-consuming up front, but this is where it all pays off.

In this exercise, you'll see how quickly you can calculate the conversion rate. A task that in previous lessons took multiple steps. By automating the repetitive parts of your work, you'll be able to spend more time doing complex analyses.

Deze oefening maakt deel uit van de cursus

Analyzing Marketing Campaigns with pandas

Cursus bekijken

Oefeninstructies

  • Use your conversion_rate() function to calculate the conversion rate in marketing by date_served and age_group and store your results in age_group_conv.
  • Unstack age_group_conv at level equal to 1 and wrap that in a call to pd.DataFrame() to create age_group_df.
  • Create a line chart to display your results from age_group_df.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# Calculate conversion rate by age_group
age_group_conv = ____(____, ['date_served', ____])
print(age_group_conv)

# Unstack and create a DataFrame
age_group_df = ____(age_group_conv.____)

# Visualize conversion by age_group
age_group_df____
plt.title('Conversion rate by age group\n', size = 16)
plt.ylabel('Conversion rate', size = 14)
plt.xlabel('Age group', size = 14)
plt.show()
Code bewerken en uitvoeren