Mean and median
In this chapter, you'll be working with the food_consumption dataset from 2018 Food Carbon Footprint Index by nu3. The food_consumption dataset contains the number of kilograms of food consumed per person per year in each country and food category (consumption), and its carbon footprint (co2_emissions) measured in kilograms of carbon dioxide, or CO2.
In this exercise, you'll compute measures of center to compare food consumption in the US and Belgium using your pandas and numpy skills.
pandas is imported as pd for you and food_consumption is pre-loaded.
Cet exercice fait partie du cours
Introduction to Statistics in Python
Instructions
- Import
numpywith the aliasnp. - Subset
food_consumptionto get the rows where thecountryis'USA'. - Calculate the mean of food
consumptionin theusa_consumptionDataFrame, which is already created for you. - Calculate the median of food
consumptionin theusa_consumptionDataFrame.
Exercice interactif pratique
Essayez cet exercice en complétant cet exemple de code.
# Import numpy with alias np
____
# Subset country for USA: usa_consumption
usa_consumption = ____
# Calculate mean consumption in USA
print(____)
# Calculate median consumption in USA
print(____)