"A/B Testing for ShoeFly.com" problem with step #6

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

I am trying to solve this part by using the following lambda function:

clicks_pivot['percent_clicked'] = clicks_pivot.apply(lambda row: row['True'] / (row['False'] + row['True']), index=1)

But it is not working and I can’t see why it won’t work!

Could anyone help me ?

Thanks in advance

I am also new on Python and I just completed this project.
Firstly, it is axis=1, not index=1.
Secondly, you don’t need to quote the True and False, I don’t know why but I assume it’s because they are reserved or unique variables in Python.
Thirdly, it seems like Lambda returns integer so all the percentage will be 0. However, you can add 100* into the Lambda calculation. The result looks the same as mine.

At begging I was also thinking about using Lambda on this task, but I just simply used basic column adding function, here is my code:

clicks_pivot['percent_clicked'] = clicks_pivot[True]/(clicks_pivot[True]+clicks_pivot[False])

1 Like