March 2019
Beginner to intermediate
464 pages
10h 57m
English
So far, we have aggregated our data by one criterion. However, there are cases where you want to group the data by more than one column. In this section, we will discuss how we can analyze and report conversion rates by more than one criterion. As an exercise, we will use age groups that we have built in the previous section and the marital status as the two columns to group by.
Let's first look at the code:
age_marital_df = df.groupby(['age_group', 'marital'])['conversion'].sum().unstack('marital').fillna(0)age_marital_df = age_marital_df.divide( df.groupby( by='age_group' )['conversion'].count(), axis=0)
As you can see from this code, we are grouping our data by the two columns, age_group and marital ...
Read now
Unlock full access