This topic material is based on the Python Programming for Data Science book and adapted for our purposes in the course.
In this set of practice exercises we'll be investigating the carbon footprint of different foods. We'll be leveraging a dataset compiled by Kasia Kulma and contributed to R's Tidy Tuesday project.
Start by importing pandas with the alias pd
.
# Your answer here.
The dataset we'll be working with has the following columns:
column | description |
---|---|
country | Country Name |
food_category | Food Category |
consumption | Consumption (kg/person/year) |
co2_emmission | Co2 Emission (Kg CO2/person/year) |
Import the dataset as a dataframe named df
from this url: https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2020/2020-02-18/food_consumption.csv
# Your answer here.
How many rows and columns are there in the dataframe?
# Your answer here.
What is the type of data in each column of df
?
# Your answer here.
What is the mean co2_emission
of the whole dataset?
# Your answer here.
How many different kinds of foods are there in the dataset? How many countries are in the dataset?
# Your answer here.
What is the maximum co2_emmission
in the dataset and which food type and country does it belong to?
# Your answer here.
How many countries produce more than 1000 Kg CO2/person/year for at least one food type?
# Your answer here.
Which country consumes the least amount of beef per person per year?
# Your answer here.
Which country consumes the most amount of soybeans per person per year?
# Your answer here.
What is the total emissions of all the meat products (Pork, Poultry, Fish, Lamb & Goat, Beef) in the dataset combined?
# Your answer here.
What is the total emissions of all other (non-meat) products in the dataset combined?
# Your answer here.
!jupyter nbconvert _07-py-pandas-practice.ipynb --to html --template classic --output 07-py-pandas-practice.html