ComeçarComece de graça

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.

Este exercício faz parte do curso

Introduction to Statistics in Python

Ver curso

Instruções do exercício

  • Import numpy with the alias np.
  • Subset food_consumption to get the rows where the country is 'USA'.
  • Calculate the mean of food consumption in the usa_consumption DataFrame, which is already created for you.
  • Calculate the median of food consumption in the usa_consumption DataFrame.

Exercício interativo prático

Experimente este exercício completando este código de exemplo.

# 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(____)
Editar e executar o código