不同年齡層的行銷管道
一些行銷利害關係人想知道,各行銷管道是否同樣觸及所有使用者,或是某些行銷管道特別集中在特定年齡族群。
在行銷團隊中,很常會接到需要快速分析與視覺化的需求。你越能把結果視覺化得清楚,就越能有效將你的發現傳達給利害關係人。
在這個練習中,你會建立一個群組長條圖,顯示各行銷管道在不同年齡層觸及了多少人。
本練習屬於課程
使用 pandas 分析行銷活動
練習說明
- 以
level = 1對channel_age進行 unstack,並將結果轉成 DataFrame。 - 將
channel_age繪製為群組長條圖。 - 在右上角加入圖例,並將標籤設為
channel_age_df.columns.values。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
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()