Hi, I have a question related to this exercise. This course is found in pandas section in data science track.
My question is related to Task 6: Create a new column in
percent_clicked which is equal to the percent of users who clicked on the ad from each
This is my original attempt, and the
percent_clicked column showed incorrect result:
percent = lambda row: row[True]/(row[False] + row[True]) clicks_pivot["percent_clicked"] = clicks_pivot.apply(percent, axis = 1)
A answer before states that lambda function returns an integer, so one should multiply the expression by 100, but it doesn;t work.
The hint in the question is as below:
clicks_pivot['percent_clicked'] = \ clicks_pivot[True] / \ (clicks_pivot[True] + clicks_pivot[False])
Although the second method is intuitive, I am still curious that why doesn’t the first method can’t show the correct result.