1. Initial exploratory analysis
Now that you've imported the marketing dataset and are familiar with it let's do some initial exploratory analysis.
2. How many users see marketing assets?
To begin, let's get a sense of how many unique users see our marketing assets each day.
We can use the groupby() method on the marketing DataFrame. To group by date, we pass 'date_served' as the argument to groupby(). Next, we select the user_id column outside of the groupby() and use nunique() method to count the number of unique users each day.
Looks like about 300 users each day see our ads.
3. Visualizing results
As you saw on the previous slide, it's not easy to interpret results when they're printed in a table. It's much easier to notice fluctuations in our metrics when we plot them.
We first import matplotlib dot pyplot as plt. Then, we plot the series daily_users.
It's good practice to always add title and labels to your plot in order to clearly convey what information the chart contains. You can add a title using plt dot title(), and add x and y labels using plt dot xlabel() and plt dot ylabel() functions, respectively.
We also rotate the xticks, in this case, the date labels, by 45 degrees to increase legibility.
Finally, don't forget to include a call to plt dot show() to display the plot.
4. Daily users plot
As you can see, while the first half of the month sticks around 300 users per day, there's a huge spike in the middle of the month. This may be because we sent out a big marketing email, which reached many users who are not daily visitors of the site. These are the kinds of fluctuations we want to be aware of before diving in and calculating metrics.
5. Let's practice!
Now it's your turn to analyze this data.