Creating a DataFrame for house ads
The house ads team is concerned because they've seen their conversion rate drop suddenly in the past few weeks. In the previous exercises, you confirmed that conversion is down because you noticed a pattern around language preferences.
As a data scientist, it is your job to provide your marketing stakeholders with as specific feedback as possible as to what went wrong to maximize their ability to correct the problem. It is vital that you not only say "looks like there's a language problem," but instead identify what the problem is specifically so that the team doesn't repeat their mistake.
Este exercício faz parte do curso
Analyzing Marketing Campaigns with pandas
Instruções do exercício
- Use
np.where()
to create a new column inhouse_ads
called'is_correct_lang'
whose values are'Yes'
if'language_displayed'
is equal to'language_preferred'
and'No'
otherwise. - Group by
date_served
andis_correct_lang
to get a daily count of the ads served.
Exercício interativo prático
Experimente este exercício completando este código de exemplo.
# Add the new column is_correct_lang
house_ads['is_correct_lang'] = np.____(
house_ads['____'] == house_ads['____'],
'____',
'____')
# Groupby date_served and correct_language
language_check = house_ads.____(____)['____'].____()
# Unstack language_check and fill missing values with 0's
language_check_df = pd.DataFrame(language_check.unstack(level=1)).fillna(0)
# Print results
print(language_check_df)