Complete the code to create a KPI card showing total website visits.
total_visits = df['[1]'].sum()
The column website_visits contains the total visits data, so summing it gives total visits.
Complete the code to calculate the average conversion rate.
avg_conversion = df['[1]'].mean()
The conversion_rate column holds the conversion percentages, so averaging it gives the average conversion rate.
Fix the error in the code to filter data for the last 30 days.
recent_data = df[df['date'] [1] pd.Timestamp.today() - pd.Timedelta(days=30)]
To get data from the last 30 days, we select dates greater than or equal to today minus 30 days.
Fill both blanks to create a dictionary of average clicks and impressions per campaign.
avg_metrics = {campaign: {'clicks': [1], 'impressions': [2] for campaign in campaigns}We calculate the mean clicks and impressions for each campaign by filtering the dataframe and taking the mean of respective columns.
Fill all three blanks to create a KPI summary with total visits, average conversion rate, and max bounce rate.
kpi_summary = {'total_visits': [1], 'avg_conversion': [2], 'max_bounce': [3]The KPI summary dictionary holds total visits (sum of website_visits), average conversion rate (mean of conversion_rate), and maximum bounce rate (max of bounce_rate).