A/B Testing for Shoefly Steps 4 & 10

https://www.codecademy.com/paths/data-science/tracks/data-processing-pandas/modules/dspath-agg-pandas/projects/pandas-shoefly-ab-test

In the steps 4 and 10 for this project, I am a little confused by the syntax for calculating the percentages.

a_clicks_pivot['percent_clicked = is clear enough, we are adding a new column, but for the calculation: a_clicks_pivot[True] / (a_clicks_pivot[True] + a_clicks_pivot[False]) , is this just selecting all rows in a_clicks_pivot that have a row where the value equals True?

I don’t immediately see what that [True] part is referencing.

Can’t access this but from context it seems like there are True and False values that track a_clicks_pivot.

The True references that something is clicked, False something that it isn’t. Summing them together gives you the total clicks. Hence: a_clicks_pivot[True] / (a_clicks_pivot[True] + a_clicks_pivot[False]) provides the percentage that is True, i.e. the percent clicked.

2 Likes