The first statistical concept we’ll explore is mean, also commonly referred to as an average. The mean is a useful measurement to get the center of a dataset. NumPy has a built-in function to calculate the average or mean of arrays: np.mean

Let’s say we want to find the average number of pounds of produce a person purchases per week. We administered a survey and received 1,000 responses:

survey_responses = [5, 10.2, 4, .3 ... 6.6]

We can then transform the dataset into a NumPy array and use the function np.mean to calculate the average:

>>> survey_array = np.array(survey_responses) >>> np.mean(survey_array) 5.220



The beverage distributor, Wine Not? wants to calculate how many bottles of Bordeaux it sells on average at three area wine sellers to determine whether or not it should increase its stock. The sales for the past week for each store are listed in script.py.

Find the average sales for each store, and save them to the variables store_one_avg, store_two_avg, and store_three_avg.


Print the averages to the terminal.


Notice the average sales per week for each store. The boss says that we should increase what we stock, but only if the store’s average sales are greater than 7 bottles per week.

Save the store dataset variable name that fits this description to the variable best_seller.

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?