The marketing department at Live-it-LIVE reports that, during this time of year, about 10% of visitors to Live-it-LIVE.com make a purchase.

The monthly report shows every visitor to the site and whether or not they made a purchase. The checkout page had a small bug this month, so the business department wants to know whether the purchase rate dipped below expectation. They’ve asked us to investigate this question.

In order to run a hypothesis test to address this, we’ll first need to know two things from the data:

  • The number of people who visited the website
  • The number of people who made a purchase on the website

Assuming each row of our dataset represents a unique site visitor, we can calculate the number of people who visited the website by finding the number of rows in the data frame. We can then find the number who made a purchase by using a conditional statement to add up the total number of rows where a purchase was made.

For example, suppose that the dataset candy contains a column named chocolate with 'yes' recorded for every candy that has chocolate in it and 'no' otherwise. The following code calculates the sample size (the number of candies) and the number of those candies that contain chocolate:

## sample size (number of rows): samp_size = len(candy) ## number with chocolate: total_with_chocolate = np.sum(candy.chocolate == 'yes')



Each row of the dataset monthly_report represents a single visitor to Live-it-LIVE.com during the week in question. Use .head() to print the first five rows of the data once again and inspect the 'purchase' column. What are the values and how can you tell whether someone made a purchase?

Note that this will print in both the output terminal and the web browser, but it will look nicer and be easier to read in the web browser.


Calculate the sample size and assign it to a variable named sample_size. Print sample_size. How many visitors accessed the website this week?

Note that this will print to the output terminal, not the web browser.


Calculate the number of visitors who made a purchase this week and save it to a variable named num_purchased. Print num_purchased. How many visitors made a purchase this week?

Note that this will print to the output terminal, not the web browser.

Sign up to start coding

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?