{"cells":[{"metadata":{},"cell_type":"markdown","source":"# KPIs for Food Waste, Insecurity, & Overconsumption\n\n\nIn this notebook, we will explore the impact of food insecurity, meat overconsumption and food waste. \n\n***Food waste*** is food that is not eaten. Food waste occurs throughout the food system, during production, processing, distribution, retail and consumption. Food waste has a substantial environmental impact and it is a major source of greenhouse emissions. Overbuying, overproduction, and spoilage are the main causes of food waste [[8](#ref_8)]. \n\n***Food insecurity*** [[1](#ref_1)] is the inability to consume an adequate diet quality or sufficient quantity of food. Household food insecurity is often linked with the household's financial ability to access adequate food. The United States Department of Agriculture (USDA) divides food insecurity into the following 2 categories: Low food security and Very low food security[[2](#ref_2)]. In 2018, 9.2% of the world population were defined as severely food insecure. Food insecurity is highest in Sub-Saharan Africa where nearly one-third are defined as severely insecure [[3](#ref_3)].\n\n***Food overconsumption*** refers to a state in which food intake exceeds individual food requirements, providing an excess of nutrients and energy [[4](#ref_4)]. Almost 20% of the food made available to consumers is lost through over-eating or waste [[5](#ref_5)]. The world population consumes around 10% more food than it needs, while almost 9% is thrown away or left to spoil [[5](#ref_5)]. \n\n***Meat Overconsumption*** is where a person eats more than their recommended daily intake. Meat overconsumption has been linked to numerous negative health impacts, including: heart disease, obesity, stroke, cancers, type 2 diabetes, and a shorter life span [[6](#ref_6)]. We will mainly focus on the environmental impact of meat overconsumption because it has a huge footprint when it comes to CO2 emissions and water security [[7](#ref_7)].\n\nFood waste, food insecurity and meat overconsumption have roots in a concept called the ***Tragedy of the Commons***. The tragedy of the commons [[11](#ref_11)] is a situation in a shared-resource system where individual users act to maximize their self-interest. They end up depleting the shared resource and behaving in a way contrary to the common good. Overfishing is a great example of this where people try to catch as much fish as they can, which may drive the fish population to extinction. In a similar manner, because of the gap in purchasing power among people, people with larger purchasing power have the incentive to overbuy items without considering the impact of their buying patterns on the environment. A lot of food end up wasted because of this. On the other hand, people with lower purchasing power may face food insecurity because they can't afford buying food.\n\nHere's a great video to explain this concept:\n\n<iframe width=\"560\" height=\"315\" src=\"https://www.youtube.com/embed/lj_gLquca7Q\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen></iframe>\n\n<br>\n\nWe will develop three KPIs that speak to the social and environmental issues facing our world when it comes to food waste, food insecurity, and meat overconsumption. This notebook explicitly emphasizes the social aspect of climate change.\n\n| KPI      |Type| Description |\n| :---     | :---         | :---      |\n| Food Waste Per Capita Nutrition Loss | Social Vulnerability + Environmental| This KPI measures the per capita nutrition loss expressed in terms of the number of people who could have met their nutritional needs if the food was not wasted.       |\n| Food Loss Per Food-Insecure Population| Social Vulnerability + Environmental| This KPI measures the average amount of food in kilograms that a food-insecure person could have received if the food was not wasted.|\n| Meat Overconsumption | Environmental + Public Health| This KPI measures the magnitude of meat overconsumption. In addition, it can be used to estimate the  environmental impact of exceeding the meat consumption limit recommended by health experts. Furthermore, it can be used to estimate the CO2 emissions and water waste as a result of exceeding the limit.|\n\n<br>\n\nIn the next section, we will introduce the Healthy Diet dataset, which is a dataset that explains the ideal food consumption patterns. \n\n# Table of Contents\n* [Section 1: The Healthy Diet Dataset](#sec_1)\n* [Section 2: Food Waste Per Capita Nutrition Loss KPI](#sec_2)\n* [Section 3: Food Loss Per Food Insecure KPI](#sec_3)\n* [Section 4: Meat Overconsumption KPI](#sec_4)\n* [Summary & Conclusion](#sec_conclusion)\n* [References](#sec_references)"},{"metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true,"_kg_hide-input":true,"_kg_hide-output":true},"cell_type":"code","source":"from mpl_toolkits.basemap import Basemap\nfrom shapely.geometry import Polygon\nfrom plotly.subplots import make_subplots\nimport plotly.graph_objects as go\nimport plotly_express as px\nimport geopandas as gpd\nimport seaborn as sns\nimport folium\n\nimport matplotlib.pyplot as plt\nimport pandas as pd\nimport numpy as np\nimport math\nimport json\nimport csv\nimport re\nimport os\n\n\nfrom plotly.offline import init_notebook_mode;\ninit_notebook_mode(connected=True)\n\nprint(os.getcwd())","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"d629ff2d2480ee46fbb7e2d37f6b5fab8052498a","_cell_guid":"79c7e3d0-c299-4dcb-8224-4455121ee9b0","trusted":true,"_kg_hide-input":true,"_kg_hide-output":true},"cell_type":"code","source":"# Some Variables\npie_colors = [\"#083069\", \"#1F6EB1\", \"#6BAED6\", \"E7F1FA\"]\nresponses_labels = ['Provided Information', 'No Information']\n\nfwaste_cities_shorter_names = {'eThekwini Municipality': 'eThekwini',  'Comune di Milano': 'Milano',  'Mexico City': 'Mexico City', 'Ajuntament de Barcelona': 'Barcelona', \n                               'City of Sydney': 'Sydney',  'Gemeente Rotterdam': 'Rotterdam', 'City of Athens': 'Athens',  'City of Phoenix': 'Phoenix', \n                               'Dhaka City': 'Dhaka', 'City of Stockholm': 'Stockholm',  'City of Yokohama': 'Yokohama',  'Moscow Government': 'Moscow', 'District of Columbia': 'Washington, DC',\n                               'City of Toronto': 'Toronto',  'City of Seattle': 'Seattle', 'Greater London Authority': 'London',  'Auckland Council': 'Auckland',\n                               'City of Cape Town': 'Cape Town',  'City of Boston': 'Boston',  'Corporation of Chennai': 'Chennai', 'City of Paris': 'Paris', \n                               'City of Dar es Salaam': 'Dar es Salaam', 'Distrito Metropolitano de Quito': 'Quito',  'Prefeitura do Rio de Janeiro': 'Rio de Janeiro',\n                               'The Executive Council, Govt of Dubai': 'Dubai',  'City of San Francisco': 'San Francisco', 'Seoul Metropolitan Government': 'Seoul', \n                               'City of Buenos Aires': 'Buenos Aires', 'Government of Hong Kong Special Administrative Region': 'Hong Kong',\n                               'Tokyo Metropolitan Government': 'Tokyo'}\nmeat_cities_shorter_names = {'City of Delhi': 'Delhi', 'Dhaka City': 'Dhaka', 'Malmö Stad': 'Malmö Stad', 'Municipalidad Distrital de Jesús María': 'Jesús María', \n                             'City of Denizli': 'Denizli','Municipalidad de Comas': 'Comas', 'Corporation of Chennai': 'Chennai', 'Dijon métropole': 'Dijon métropole', \n                             'Göteborgs Stad': 'Göteborgs Stad', 'City of Dar es Salaam': 'Dar es Salaam', 'Municipality of Trelleborg': 'Trelleborg', \n                             'Riga City': 'Riga', 'Gemeente Rotterdam': 'Gemeente Rotterdam', 'Sofia Municipality': 'Sofia', 'Greater Amman Municipality': 'Amman', \n                             'Prefeitura de São Leopoldo': 'São Leopoldo', 'City of Paris': 'Paris', 'Tokyo Metropolitan Government': 'Tokyo', 'Município de Viseu': 'Viseu', \n                             'Greater London Authority': 'London', 'Prefeitura do Rio de Janeiro': 'Rio de Janeiro', 'Seoul Metropolitan Government': 'Seoul', \n                             'The Executive Council, Govt of Dubai': 'Dubai', 'Ayuntamiento de Vitoria-Gasteiz': 'Vitoria-Gasteiz',\n                             'Wandsworth Council': 'Wandsworth', 'Richmond Council': 'Richmond', 'Distrito Metropolitano de Quito': 'Quito', \n                             'Stadt Zürich': 'Zürich', 'Municipality of Arendal': 'Arendal', 'Trondheim Municipality': 'Trondheim', 'Egedal Municipality': 'Egedal', \n                             'Gladsaxe Kommune': 'Gladsaxe Kommune', 'City of Hvidovre': 'Hvidovre', 'Hoeje-Taastrup Kommune': 'Hoeje-Taastrup Kommune',\n                             'City of Vancouver': 'Vancouver', 'City of Helsinki': 'Helsinki', 'City of Berlin': 'Berlin', 'eThekwini Municipality': 'eThekwini', \n                             'District of Columbia': 'Washington, DC', 'Birmingham City Council': 'Birmingham', 'City of San Leandro, CA': 'San Leandro, CA', \n                             'Region Metropolitana de Guadalajara': 'Guadalajara', 'Umeå municipality': 'Umeå', 'Auckland Council': 'Auckland', \n                             'Bærum Kommune': 'Bærum Kommune', 'City of Turku': 'Turku', 'City of Athens': 'Athens', 'City of Lahti': 'Lahti', 'Comune di Milano': 'Milano',\n                             'Comune di Torino': 'Torino', 'City of Espoo': 'Espoo', 'Metropolitan Municipality of Lima': 'Lima', 'Wolverhampton City Council': 'Wolverhampton', \n                             'City of Stockholm': 'Stockholm', 'City of Buenos Aires': 'Buenos Aires', 'BCP Council': 'BCP', 'Tel Aviv-Yafo Municipality': 'Tel Aviv', \n                             'Moscow Government': 'Moscow', 'Municipality of Campinas': 'Campinas', 'Town of Vail, CO': 'Vail, CO', 'City of Baltimore': 'Baltimore', \n                             'City of Houston': 'Houston', 'City of Medford': 'Medford', 'City of Adelaide': 'Adelaide', 'Município de Braga': 'Braga', \n                             'Município de Évora': 'Évora', 'Município de Águeda': 'Águeda', 'City of Boston': 'Boston', 'City of Boulder': 'Boulder', \n                             'Junta Intermunicipal de Medio Ambiente Region Valles (JIMAV)': 'JIMAV',}","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"_kg_hide-output":true,"trusted":true},"cell_type":"code","source":"# Helper Functions\ndef get_city_answers(df, question_name, column_name, new_column_name, include_city, convert_to_numeric, row_name=None, dropna=True, dropNotApplicable=True):\n    \"\"\"\n    Gets the answers for a question in the city dataframe.\n    \n    Parameters\n    ----------\n        df (dataframe): The city dataframe\n        question_name (string): the question to query.\n        column_name (string): the column to query.\n        new_column_name (string): rename the column name to user friendly name.\n        include_city (boolean): if true the organization name column will be included in the returned dataframe.\n        convert_to_numeric (boolean): if true, the column will convert to numeric data type.\n        row_name(string): Optional, if not None, filter by row.\n        dropna(bool): Optional, if true, it will drop invalid rows\n        dropNotApplicable (bool): Optional, if true, it will drop Unanswered rows\n        \n    Returns\n    -------\n    result_df: The result dataframe for the input question and column\n    \"\"\"\n    \n    selected_columns = ['Account Number', 'Response Answer']\n    renamed_columns = {'Response Answer': new_column_name} \n    if include_city:\n        selected_columns = ['Organization'] + selected_columns\n        renamed_columns['Organization'] = 'City'\n\n\n    result_df = df[df['Question Name'] == question_name]\n    result_df = result_df[result_df['Column Name'] == column_name]\n    if row_name:\n        result_df = result_df[result_df['Row Name'] == row_name]\n    result_df = result_df[selected_columns].rename(columns=renamed_columns)\n        \n    # Get information about the amount of response to this question\n    total_number_of_answers = len(result_df)\n    number_of_invalid_answers = sum(result_df[new_column_name]=='Question not applicable') + sum(result_df[new_column_name].isna()) + sum(result_df[new_column_name] == '0')\n    number_of_valid_answers = total_number_of_answers-number_of_invalid_answers\n    print ('The number of cities that responded to this questions is', number_of_valid_answers)\n    print ('The number that did not respond is', number_of_invalid_answers, 'out of', total_number_of_answers)\n    \n    # # Drop unanswered responses and invalid answers\n    if dropNotApplicable:\n        result_df = result_df[result_df[new_column_name]!='Question not applicable']\n        result_df = result_df[result_df[new_column_name]!='0']\n    if dropna:\n        result_df = result_df.dropna()\n    \n    if convert_to_numeric: \n        result_df[new_column_name] = pd.to_numeric(result_df[new_column_name])\n\n    return result_df, [number_of_valid_answers, number_of_invalid_answers]\n\ndef draw_bar_chart(df, x, y, chart_title, x_title, y_title, texttemplate, chart_height, line_x, line_text):\n    \"\"\"\n    Draws Bar Chart with Line.\n    \n    Parameters\n    ----------\n        df (dataframe): The city dataframe\n        x (string): column name for x axis\n        y (string): column name for y axis\n        chart_title(string): The chart title\n        x_title(string): The X axis title\n        y_title(string): The Y axis title\n        texttemplate(string): The text template for formating numbers\n        chart_height(int): The hight of the chart\n        line_x (float, optional): if provided a line will be drawn at location x\n        line_text (string, optional): line annotation\n        \n    Returns\n    -------\n        void\n    \"\"\"\n\n    \n    bar_chart = go.Bar(x=df[x], y=df[y], orientation='h', text=df[x], textposition='auto', texttemplate=texttemplate)\n    if line_x:\n        line = go.Scatter(x=[line_x, line_x], y=[0,.99], mode=\"lines\", marker=dict(color=\"red\"), line=dict(dash='dash'))\n\n    fig = make_subplots(specs=[[{\"secondary_y\": True}]], print_grid=False)\n    fig.add_trace(bar_chart, 1, 1, secondary_y=False)\n    if line_x:\n        fig.add_trace(line, 1, 1, secondary_y=True)\n        fig.add_annotation(x=line_x, y=len(df), text=line_text, showarrow=True, arrowhead=1, bgcolor='red', font=dict(size=16, color=\"#ffffff\"))\n    fig.update_layout(title=chart_title, height=chart_height, xaxis=dict(title=x_title), yaxis = dict(title=y_title), yaxis2= dict(fixedrange= True, range= [0, 1], visible= False), showlegend=False)\n    fig.show()\n    \ndef draw_pie_chart(labels, values, chart_title, textinfo, colors = None):\n    \"\"\"\n    Draws Pie Chart.\n    \n    Parameters\n    ----------\n        labels (list): The labels\n        values (float): The values\n        chart_title(string): The chart title\n        textinfo(string): what data to show\n        colors(list of strings): the list of colors\n        \n    Returns\n    -------\n        void\n    \"\"\"\n    \n    marker=dict(colors=colors)\n    if colors:\n        marker['colors'] = colors\n    fig = go.Figure(data=[go.Pie(labels=labels, values=values, textinfo=textinfo, marker=marker)],\n                    layout = dict(title=chart_title))\n    fig.show()","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"_kg_hide-output":true,"trusted":true},"cell_type":"code","source":"# Read all data.\ndfs = {}\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        df_path = os.path.join(dirname, filename)\n        df_name = filename[:-4]\n        if filename.split('.')[-1] == 'csv':\n            dfs[df_name] = pd.read_csv(df_path)\n        else:\n            print('Ignoring Non-csv file: ', filename)\n\nprint ('Loaded the following files: ', sorted(list(dfs.keys())))","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"_kg_hide-output":true,"trusted":true},"cell_type":"code","source":"# assign dfs to variables to make it easier to work with.\ncc_2018_df = dfs['2018_Full_Climate_Change_Dataset']\ncc_2019_df = dfs['2019_Full_Climate_Change_Dataset']\ncc_2020_df = dfs['2020_Full_Climate_Change_Dataset']\n\nccd_2018_df = dfs['2018_Corporates_Disclosing_to_CDP_Climate_Change']\nccd_2019_df = dfs['2019_Corporates_Disclosing_to_CDP_Climate_Change']\nccd_2020_df = dfs['2020_Corporates_Disclosing_to_CDP_Climate_Change']\n\nws_2018_df = dfs['2018_Full_Water_Security_Dataset']\nws_2019_df = dfs['2019_Full_Water_Security_Dataset']\nws_2020_df = dfs['2020_Full_Water_Security_Dataset']\n\nwsd_2018_df = dfs['2018_Corporates_Disclosing_to_CDP_Water_Security']\nwsd_2019_df = dfs['2019_Corporates_Disclosing_to_CDP_Water_Security']\nwsd_2020_df = dfs['2020_Corporates_Disclosing_to_CDP_Water_Security']\n\nc_2018_df = dfs['2018_Full_Cities_Dataset']\nc_2019_df = dfs['2019_Full_Cities_Dataset']\nc_2020_df = dfs['2020_Full_Cities_Dataset']\n\ncd_2018_df = dfs['2018_Cities_Disclosing_to_CDP']\ncd_2019_df = dfs['2019_Cities_Disclosing_to_CDP']\ncd_2020_df = dfs['2020_Cities_Disclosing_to_CDP']\n\ntract_svi_df = dfs['SVI2018_US']# external data - import CDC social vulnerability index data - census tract level\ncounty_svi_df = dfs['SVI2018_US_COUNTY']\ncities_locs_df = dfs['uscities']# cities lat,lon locations for US cities\norgs_hq_df = dfs['NA_HQ_public_data']# CDP metadata on organisation HQ cities\nrecommended_food_serving_df = dfs['recommended_food_serving_df']","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"# Section 1: The Healthy Diet Dataset\n<a id=\"sec_1\"></a>\n\nThe Healthy Diet Dataset[[9](#ref_9)] is a small dataset that contains information about food groups along with serving information. The dataset contains 8 food items: vegetables, fruits, grains, dairy, meat, fish, nuts, and fats. For each food group, the following information is provided:\n* Serving Per Day\n* Serving Per Week\n* Serving Size\n* Serving Unit (Cups, Oz. , Tbsp)\n* Serving Example\n* Total Daily Consumption (grams)\n* Total Yearly Consumption (kg)\n* Number of Servings Per Year\n\nI created this dataset [[9](#ref_9)] and made it public on Kaggle. This dataset is based on an article published at the American Heart Association website [[10](#ref_10)]. The article provides information about the recommended daily servings for each food group. I processed the information and calculated the total yearly consumption of each food group in kilograms. The data is summarized in the following table: \n\n|Food Group|Example of 1 Serving|Recommended Yearly Consumption Weight (kg)\n| :---     | :---     | :---     |\n|Vegetables|1/2 cup cut-up vegetables|109.5|\n|Fruits|1/2 cup cut-up fruit|87.6|\n|Grains|1/2 cup cooked rice, pasta, or cereal|262.8|\n|Dairy|1 cup milk or yogurt|262.8|\n|Poultry, meat and eggs|3 oz cooked meat or poultry|39.42|\n|Fish and other seafood|3 oz cooked fish or seafood|13.14|\n|Nuts, seeds, beans and legumes|1/2 cup cooked beans or peas|3.65|\n|Fats and oils|1 Tbsp vegetable oil (canola, corn, olive, soybean, safflower)|16.425|\n||||\n||Total Yearly Food Consumption Weight|795|\n\n<br>\n\nThe most important numbers that we will use in this notebook are:\n* The total food consumption weight, which is 795 kg per person per year \n* and the total suggested meat and fish weight (39.42 kg for Poultry & red meat + 13.14 kg for fish) = 52.56 kg person per year.\n\nThis pie chart shows the suggested amount of food that should be consumed: "},{"metadata":{"_kg_hide-input":true,"_kg_hide-output":true,"trusted":true},"cell_type":"code","source":"# The Healthy Diet Dataset is a dataset that provides information about how much food a person eats in 1 year expressed in kilograms.\n# I created this dataset and made it public based on an article from: https://www.heart.org/en/healthy-living/healthy-eating/eat-smart/nutrition-basics/suggested-servings-from-each-food-group\n# I manually measured how much 1 cup of vegtables and fruit weighs so that all food groups are expressed in kg\n\n# Get the recommended meat consumption\nrecommended_meat_weight = recommended_food_serving_df[recommended_food_serving_df['food_group'].isin(['Poultry, meat and eggs', 'Fish and other seafood'])]['total_yearly_consumption(kg)'].sum()\nprint ('Health experts recommend eating', recommended_meat_weight, 'kilograms of meat')\n\ntotal_weight_recommended_servings = int(round(sum(recommended_food_serving_df['total_yearly_consumption(kg)']), 0))\nprint ('The total recommended yearly amount of food consumption is around', total_weight_recommended_servings, 'kilograms')\n\nrecommended_food_serving_df","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true},"cell_type":"code","source":"# Draw the Healthy Diet Food Group Breakdown\ndraw_pie_chart(labels=recommended_food_serving_df['food_group'], \n               values=recommended_food_serving_df['servings_per_year'], \n               chart_title='Healthy Diet', \n               textinfo='label+percent', \n               colors = None)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"The top 3 food groups are: grains, vegetables and fruits, which collectively make up 65% of a healthy diet. Health experts recommend eating meat in low quantities. Meat is only 5% of a healthy diet while fish, which is a healthier source of protein, should account for 13% of a healthy diet. \n\nBecause different food groups have different weights, the healthy diet looks different when considering the weight of each food group. As shown in the below chart, grains and dairy account for 66% of healthy diet when looking at food group weights. This is because vegetables and fruits are lighter than grains and dairy. "},{"metadata":{"_kg_hide-input":true,"_kg_hide-output":false,"trusted":true},"cell_type":"code","source":"# Draw the Weight of each food group in a Healthy Diet\ndraw_pie_chart(labels=recommended_food_serving_df['food_group'], \n               values=recommended_food_serving_df['total_yearly_consumption(kg)'], \n               chart_title='The Weights of Different Food Groups that a Person Should Consume in One Year (in Kg)', \n               textinfo='label+value+percent', \n               colors = None)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"We are now ready to move on to the next section. In the next section, we will introduce the ***Food Waste Per Capita Nutrition Loss KPI*** after performing some exploratory analysis."},{"metadata":{"_kg_hide-input":true,"_kg_hide-output":true,"trusted":true},"cell_type":"code","source":"# Get the population of the city\nc_2020_pop_df, c_2020_pop_responses = get_city_answers(df = c_2020_df, \n                                                       question_name = 'Please provide details of your city’s current population. Report the population in the year of your reported inventory, if possible.',\n                                                       column_name = 'Current population',\n                                                       new_column_name = 'Population',\n                                                       include_city = True,\n                                                       convert_to_numeric = True)\nc_2020_pop_df","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"_kg_hide-output":true,"trusted":true},"cell_type":"code","source":"# Get the amount of annual food waste in the city\nc_2020_fwaste_df, c_2020_fwaste_responses = get_city_answers(df = c_2020_df, \n                                                             question_name = 'Please report the total annual volume of food waste in tonnes.',\n                                                             column_name = 'Total annual volume of food waste in tonnes',\n                                                             new_column_name = 'Annual Food Waste (tonnes)',\n                                                             include_city = False,\n                                                             convert_to_numeric = True)\n\n\nc_2020_fwaste_df","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"# Section 2: Food Waste Per Capita Nutrition Loss KPI\n<a id=\"sec_2\"></a>\n\nBefore we introduce the ***Food Waste Per Capita Nutrition Loss KPI***, we have to explore the information that the cities provided about food waste. As shown in the below pie chart, only 30 cities provided information about the magnitude of food waste. This accounts to around 5% of the cities in the survey."},{"metadata":{"_kg_hide-input":true,"trusted":true},"cell_type":"code","source":"# Pie Chart for food waste responses\ndraw_pie_chart(labels=responses_labels, \n               values=c_2020_fwaste_responses, \n               chart_title='The Number of Cities that Provided Information About Food Waste', \n               textinfo='label+value+percent', \n               colors = pie_colors)","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"_kg_hide-output":true,"trusted":true},"cell_type":"code","source":"# Merge Food Waste with Population\nc_2020_pop_fwaste_df = pd.merge(c_2020_pop_df, c_2020_fwaste_df, on='Account Number', how='left')\n\n# Compute Food Waste per capita\nc_2020_pop_fwaste_df['Annual Food Waste per capita (kg)'] = 1000 * c_2020_pop_fwaste_df['Annual Food Waste (tonnes)'] / c_2020_pop_fwaste_df['Population']\nc_2020_pop_fwaste_df = c_2020_pop_fwaste_df.dropna()\n\nc_2020_pop_fwaste_df['City'] = c_2020_pop_fwaste_df['City'].replace(fwaste_cities_shorter_names)\n\nc_2020_pop_fwaste_df = c_2020_pop_fwaste_df.sort_values(by=['Annual Food Waste (tonnes)'], ascending=True)\nc_2020_pop_fwaste_df","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"The below bar chart shows the annual food waste measured in tonnes. The top 5 cities are Tokyo, Hong Kong, Buenos Aires, Seoul, and San Francisco. They reported the annual food waste to be 1.9 million, 1.3 million, 1.2 million, 1 million, and 960 thousand tonnes. These are big cities so it makes sense for them to be at the top of list. "},{"metadata":{"_kg_hide-input":true,"trusted":true},"cell_type":"code","source":"# Plot Annual Food Waste\ndraw_bar_chart(df = c_2020_pop_fwaste_df, \n               x = 'Annual Food Waste (tonnes)', \n               y= 'City', \n               chart_title = 'Cities Annual Food Waste in Tonnes', \n               x_title = 'Annual Food Waste (tonnes)', \n               y_title = 'City', \n               texttemplate = '%{text:.2s}', #'%{text:.2f}', '%{text:.2s}'\n               chart_height = 1000, \n               line_x = None,\n               line_text = None)","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"_kg_hide-output":true,"trusted":true},"cell_type":"code","source":"# Sort By Food Waste Per Capita\nc_2020_pop_fwaste_df = c_2020_pop_fwaste_df.sort_values(by=['Annual Food Waste per capita (kg)'], ascending=True)\nc_2020_pop_fwaste_df","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"The next chart shows the annual per capita food waste in kilograms. In other words, it measures how much one person in the city contributes to the food waste issue in the city. As mentioned in [Section 1](#sec_1), the total weight of a healthy diet that is enough to feed one person for one year is 795 kg. The city of San Francisco is on top of the list and it exceeds this limit. In other words, the food waste per one resident in San Francisco can provide enough food for one person for one year. Other cities at the top of the list include Buenos Aires, Boston, Quito, Dubai and Seattle. Tokyo, which was on the top of the list in the previous chart that reports the annual food waste in the city, performs better when looking at the per capita food waste. This is mainly because Tokyo has a large population that is close to 14 million. It should be noted that the chart shows only the cities that provided information about food waste, which as mentioned before is only 5% of the cities in the survey. Therefore, we should expect the total number of cities in the survey that exceed the red dotted line in the chart to be much higher."},{"metadata":{"_kg_hide-input":true,"_kg_hide-output":false,"trusted":true},"cell_type":"code","source":"# Cities Annual Per Capita Food Waste in Kilograms\ndraw_bar_chart(df = c_2020_pop_fwaste_df, \n               x = 'Annual Food Waste per capita (kg)', \n               y= 'City', \n               chart_title = 'Cities Annual Per Capita Food Waste in Kilograms', \n               x_title = 'Annual Per Capita Food Waste (kg)', \n               y_title = 'City', \n               texttemplate = '%{text:.2f}', #'%{text:.2f}', '%{text:.2s}'\n               chart_height = 1000, \n               line_x = total_weight_recommended_servings, # None, recommended_meat_weight, \n               line_text = 'Enough Food to Feed <br> One Person For One Year')#'None, Recommened Consumption is '+str(recommended_meat_weight)+' kgs')","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"_kg_hide-output":true,"trusted":true},"cell_type":"code","source":"################################################################\n# KPI: Food Waste Per Capita Nutrition Loss \n\n# Description: This KPI measures the per capita nutrition loss expressed in terms of the number of people who could\n# have met their nutritional needs if the food was not wasted.\n\n# Type: Social Vulnerability KPI\n\n# Use Case: This KPI can be used to measure the magnitude of the opportunity cost of not being able to avoid \n# food waste. In addition, can be used to raise awareness about the problem of food waste. \n\n# Example: If the result is 2, it means that the nutrition loss is equal to feeding to 2 people for 1 year.\n\n# Formula: (Annual Food Waste per capita - Annual Food Saved per capita) / Annual Weight of a Healthy Diet\n################################################################\n\nfood_saved_per_capita = 0\nc_2020_pop_fwaste_df['Nutrition Loss Per Capita KPI'] = (c_2020_pop_fwaste_df['Annual Food Waste per capita (kg)'] - food_saved_per_capita) / total_weight_recommended_servings\nc_2020_pop_fwaste_df","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"We are now ready to introduce the ***Food Waste Per Capita Nutrition Loss KPI***. The Food Waste Per Capita Nutrition Loss KPI measures the per capita nutrition loss expressed in terms of the number of people who could have met their nutritional needs if the food was not wasted. For instance, if the result of the KPI is 2, it means that the nutrition loss is equal to feeding 2 people for 1 year. The Food Waste Per Capita Nutrition Loss KPI can be computed as shown below:\n\n$$ Food Waste Per Capita Nutrition Loss = \\frac {W_{capita} - S_{capita}} {D} $$\n\nwhere $W_{capita}$ is the annual food waste per capita, $S_{capita}$ is the annual food saved per capita, and $D$ is the weight of a healthy diet that is sufficient for one person for one year. The cities can minimize this KPI by maximizing annual food saved $S_{capita}$. The Food Waste Per Capita Nutrition Loss KPI is a social vulnerability KPI. It is also an environmental KPI because food waste has a significant carbon footprint. Indeed, 1 kg of food waste produces 2.5 kg of CO2 emissions [[12](#ref_12)]. \n\nThe chart below shows the result of computing this KPI for each city. It should be noted that I set $S_{capita}$ to 0 when creating this chart because we don't have this information. However, in a real life scenario, we can measure the amount of food saved as a result of introducing a new technology or a new initiatives that aims to reduce food waste. There are a lot of initiatives that aim to reduce food waste. A few examples is shown in [[13](#ref_13)].\n\nAs shown in the chart below, in San Francisco, the amount of food waste per capita is 1.4, which is equivalent to feeding 1.4 people for one year. "},{"metadata":{"_kg_hide-input":true,"trusted":true},"cell_type":"code","source":"#Cities Nutrition Loss Per Capita KPI\ndraw_bar_chart(df = c_2020_pop_fwaste_df, \n               x = 'Nutrition Loss Per Capita KPI', \n               y= 'City', \n               chart_title = 'Food Waste Per Capita Nutrition Loss <br> (The Number of People whose Nutritional Needs Could Have Been Met If the Food Was Not Wasted)', \n               x_title = 'Number of People', \n               y_title = 'City', \n               texttemplate = '%{text:.2f}', #'%{text:.2f}', '%{text:.2s}'\n               chart_height = 1000, \n               line_x = 1, # None, recommended_meat_weight, \n               line_text = 'Enough Food to Feed <br> One Person For One Year')#'None, Recommened Consumption is '+str(recommended_meat_weight)+' kgs')","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"This is the end of [Section 2](#sec_2). In [Section 3](#sec_3), we will introduce the ***Food Loss Per Food-Insecure Population KPI***."},{"metadata":{"_kg_hide-input":true,"_kg_hide-output":true,"trusted":true},"cell_type":"code","source":"# Get the Food Insecurity Information\nc_2020_finsec_df, c_2020_finsec_responses = get_city_answers(df = c_2020_df, \n                                                             question_name = 'What percentage of your population is food insecure?',\n                                                             column_name = 'Percentage of population that is food insecure', \n                                                             new_column_name = 'Food Insecurity Population Percentage',\n                                                             include_city = False,\n                                                             convert_to_numeric = True)\n\nc_2020_finsec_df","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"# Section 3: Food Loss Per Food-Insecure Population KPI\n<a id=\"sec_3\"></a>\n\nWe will first analyze the information that the cities provided about food insecurity among their residents before introducing the ***Food Loss Per Food-Insecure Population KPI***. The below chart shows the number of cities that provided information about their food-insecure population. Only 34 cities responded to this question, which is about 6% of the cities in the survey."},{"metadata":{"_kg_hide-input":true,"trusted":true},"cell_type":"code","source":"# Pie Chart for Food Insecurity responses\ndraw_pie_chart(labels=responses_labels, \n               values=c_2020_finsec_responses, \n               chart_title='The Number of Cities that Provided Information About Food Insecurity in their Population', \n               textinfo='label+value+percent', \n               colors = pie_colors)","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"_kg_hide-output":true,"trusted":true},"cell_type":"code","source":"# Merge Food Waste with Food Insecurity\nc_2020_pop_fwaste_finsec_df = pd.merge(c_2020_pop_fwaste_df, c_2020_finsec_df, on='Account Number', how='left')\nc_2020_pop_fwaste_finsec_df = c_2020_pop_fwaste_finsec_df.dropna()\nc_2020_pop_fwaste_finsec_df = c_2020_pop_fwaste_finsec_df.sort_values(by=['Food Insecurity Population Percentage'], ascending=True)\nc_2020_pop_fwaste_finsec_df['Food Insecurity Population Percentage'] = c_2020_pop_fwaste_finsec_df['Food Insecurity Population Percentage']/100\nc_2020_pop_fwaste_finsec_df","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"As shown in the bar chart below, the top 5 cities when it comes to the percentage of food-insecure people in the population are eThekwini (70%), Phoenix (43%), London (38%), Cape Town (31%), and San Francisco (27%). The cities with the lowest percentage of food-insecure people include: Paris (6%), Buenos Aires (5%), Athens (4%), Seoul (3%), Dubai (2%), and Auckland (2%). "},{"metadata":{"_kg_hide-input":true,"trusted":true},"cell_type":"code","source":"# The Percentage of the Food-Insecure Population\ndraw_bar_chart(df = c_2020_pop_fwaste_finsec_df, \n               x = 'Food Insecurity Population Percentage', \n               y= 'City', \n               chart_title = 'The Percentage of the Food-Insecure Population', \n               x_title = 'Food Insecurity Population Percentage', \n               y_title = 'City', \n               texttemplate = '%{text:%}', #'%{text:.2f}', '%{text:.2s}', '%{text:%}'\n               chart_height = 1000, \n               line_x = None,\n               line_text = None)","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"_kg_hide-output":true,"trusted":true},"cell_type":"code","source":"################################################################\n# KPI: Food Loss Per Food Insecure\n\n# Description: This KPI measures the average amount of food in kilograms that a food-insecure person could have \n# received if the food was not wasted.\n\n# Type: Social Vulnerability KPI\n\n# Use Cases: This KPI can be used to estimate the impact of food waste in terms of the food-insecure \n# population for programs that try to donate food to vulnerable people before it expires.\n\n# Example: If the result is 10, it means that one person from the food-insecure population could have potentially \n# received 10 kilograms of food.\n\n# Formula: 1000 * (Annual Food Waste - Annual Food Saved) / (Percentage of Food-Insecure Population * Population)\n################################################################\n\nfood_saved = 0\nc_2020_pop_fwaste_finsec_df['Food Insecure Population'] = c_2020_pop_fwaste_finsec_df['Food Insecurity Population Percentage'] * c_2020_pop_fwaste_finsec_df['Population']\nc_2020_pop_fwaste_finsec_df['Food Loss per Food-Insecure Person KPI'] = 1000 * (c_2020_pop_fwaste_finsec_df['Annual Food Waste (tonnes)'] - food_saved) / c_2020_pop_fwaste_finsec_df['Food Insecure Population']\nc_2020_pop_fwaste_finsec_df = c_2020_pop_fwaste_finsec_df.sort_values(by=['Food Loss per Food-Insecure Person KPI'], ascending=True)\n\nc_2020_pop_fwaste_finsec_df","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"The ***Food Loss Per Food-Insecure Population KPI*** is a great KPI for programs and initiatives that deliver food to food banks in order to serve it to the food-insecure population before it goes to waste. It measures the average amount of food in kilograms that a food-insecure person could have potentially received if the food was not wasted. For instance, if the result is 10 kg, it means that one person from the food-insecure population could have potentially received 10 kilograms of food. Here is the equation:\n\n$$ Food Loss Per Food Insecure Population KPI = 1000 * \\frac {W_{city} - S_{city}} {P_{foodinsecure} * P_{city}} $$\n\nwhere $W_{city}$ is the city-wide annual food waste, $S_{capita}$ is the city-wide annual food saved,  $P_{foodinsecure}$ is the percentage of food-insecure population, and $P_{city}$ is the population of the city. \n\nThis KPI can be minimized by maximizing the city-wide food that is saved ($S_{city}$). Because the denominator contains the food-insecure population, cities with low food-insecure population will be penalized more. This makes this KPI ideal for cities with small food-insecure populations because it will incentivize them to work even harder to close the gap between food waste and food insecurity. For example, the city of Seoul performs relatively well on the Food Waste Per Capita Nutrition Loss KPI which was introduced in [Section 2](#sec_2). However, as shown in the bar chart below, the city of Seoul is performing worse on the Food Loss Per Food-Insecure Population KPI because it has a relatively small food-insecure population. At the same time, this KPI is not suitable for cities with large food-insecure populations. For instance, the city of eThekwini is doing the best as shown in the chart below and that's because it has a large food-insecure population, which is 70% of its population. Generally speaking, the Food Waste Per Capita Nutrition Loss KPI introduced in [Section 2](#sec_2) should be used by any city regardless of its food-insecure population. If the city has a small food-insecure population, the Food Loss Per Food-Insecure Population KPI is a great incentivizer."},{"metadata":{"_kg_hide-input":true,"trusted":true},"cell_type":"code","source":"# The Percentage of the Food-Insecure Population\ndraw_bar_chart(df = c_2020_pop_fwaste_finsec_df, \n               x = 'Food Loss per Food-Insecure Person KPI', \n               y= 'City', \n               chart_title = 'Food Loss Per Food-Insecure KPI <br>(The Average Amount of Food That Could Have Been Given to 1 Food-Insecure Person )', \n               x_title = 'Food Loss per Food-Insecure Person (kg)', \n               y_title = 'City', \n               texttemplate = '%{text:.2f}', #'%{text:.2f}', '%{text:.2s}', '%{text:%}'\n               chart_height = 1000, \n               line_x = None, # None, recommended_meat_weight, \n               line_text = None)#'None, Recommened Consumption is '+str(recommended_meat_weight)+' kgs')","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"In the next section, we will introduce the last KPI, which can be used to estimate the CO2 emissions and water resulting from meat overconsumption."},{"metadata":{"_kg_hide-input":true,"_kg_hide-output":true,"trusted":true},"cell_type":"code","source":"# Get Information About Meat Consumption\nc_2020_meat_df, c_2020_meat_responses = get_city_answers(df = c_2020_df, \n                                                         question_name = 'What is the per capita meat and dairy consumption (kg/yr) in your city?',\n                                                         column_name = 'Amount', \n                                                         row_name = 'Meat consumption per capita (kg/year)',\n                                                         new_column_name = 'Meat Consumption per Capita',\n                                                         include_city = False,\n                                                         convert_to_numeric = True)\n\nc_2020_meat_df","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"# Section 4: Meat Overconsumption KPI\n<a id=\"sec_4\"></a>\n\nBefore we introduce the Meat Overconsumption KPI, let's see the number of cities that provided information about meat overconsumption. As shown in the chart below, 74 cities provided information about the meat consumption per capita."},{"metadata":{"_kg_hide-input":true,"trusted":true},"cell_type":"code","source":"# Pie Chart for Meat Consumption responses\ndraw_pie_chart(labels=responses_labels, \n               values=c_2020_meat_responses, \n               chart_title='The Number of Cities that Provided Information About Meat Consumption Per Capita', \n               textinfo='label+value+percent', \n               colors = pie_colors)","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"_kg_hide-output":true,"trusted":true},"cell_type":"code","source":"# Merge the meat and population information\nc_2020_pop_meat_df = pd.merge(c_2020_pop_df, c_2020_meat_df, on='Account Number', how='left')\nc_2020_pop_meat_df = c_2020_pop_meat_df.dropna()\n\n# Some Cities privided Consumption for the whole population, we will drop these 4 rows\nc_2020_pop_meat_df = c_2020_pop_meat_df[c_2020_pop_meat_df['Meat Consumption per Capita']<1000]\n\n# Replace long city names\nc_2020_pop_meat_df['City'] = c_2020_pop_meat_df['City'].replace(meat_cities_shorter_names)\n\nc_2020_pop_meat_df = c_2020_pop_meat_df.sort_values(by=['Meat Consumption per Capita'], ascending=True)\nc_2020_pop_meat_df","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"Using the Healthy Diet dataset which we introduced in [Section 1](#sec_1), we know that a well-balanced diet has a limit on the amount of meat that should be consumed in one year. Meat is an excellent source of protein, iron, zinc, selenium and vitamin B [[14](#ref_14)]. However, a person should not eat more than 52.56 kg of meat per year. That's because meat has been linked to numerous negative health impacts, including: heart disease, cancer, diabetes, obesity and stroke [[6](#ref_6)]. Furthermore, meat production has a devastating impact on our environment [[7](#ref_7)]. The next pie chart shows that of the cities that provided information about meat consumption, 52% are exceeding the meat consumption per capita limit. "},{"metadata":{"_kg_hide-input":true,"trusted":true},"cell_type":"code","source":"# The Number of Cities that exceeds the Recommended Meat Consumption per Capita\n# The recommended meat consumption is 52.56 kgs per year. \n\nmeat_above_limit = sum(c_2020_pop_meat_df['Meat Consumption per Capita'] > recommended_meat_weight)\nmeat_under_limit = sum(c_2020_pop_meat_df['Meat Consumption per Capita'] <= recommended_meat_weight)\n\ndraw_pie_chart(labels=['Above Limit', 'Under Limit'], \n               values=[meat_above_limit, meat_under_limit], \n               chart_title='The Percentage of Cities that Exceeded the Recommended Meat Consumption', \n               textinfo='label+percent', \n               colors = pie_colors)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"The bar chart below shows the yearly meat consumption per capita in kilograms along with the recommended consumption (shown as a red line). The consumption of meat in Jimav is 178 kg, which is 3.4 times the recommended limit. In Boston, meat consumption is twice the recommended limit. This has a devastating impact on our environment."},{"metadata":{"_kg_hide-input":true,"trusted":true},"cell_type":"code","source":"# Yearly Meat Consumption per Capita (kg)\ndraw_bar_chart(df = c_2020_pop_meat_df, \n               x = 'Meat Consumption per Capita', \n               y= 'City', \n               chart_title = 'Yearly Meat Consumption per Capita in Kilograms', \n               x_title = 'Yearly Meat Consumption per Capita (kg)', \n               y_title = 'City', \n               texttemplate = '%{text:.2f}', \n               chart_height = 1500, \n               line_x = recommended_meat_weight, \n               line_text = 'Recommened Consumption is '+str(recommended_meat_weight)+' kgs')","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"_kg_hide-output":true,"trusted":true},"cell_type":"code","source":"################################################################\n# KPI: Meat Overconsumption\n\n# Description: This KPI measures the magnitude of meat overconception. In addition, it can be used to estimate the \n# environmental impact of exceeding the meat consumption limit recommended by health experts. Furthermore, it can\n# be used to estimate CO2 and Water waste as a result of exceeding the limit.\n\n# Type: Environmental KPI + General Health KPI\n\n# Use Cases: This KPI can be used to quantify the amount of overconsumed meat in the city. In addition to the \n# environmental issues that this KPI speaks to, it can also be used to raise awarance about the potential\n# health issues associated with meat overconsumption such as heart disease, diabetes and cancer.\n\n# Example: If the result is 100, it means that the population of the city collectively overconsumed meat equal \n# to 100 tonnes of meat. \n\n# Formula: (Annual Meat Consumption per Capita - Annual Recommended Meat Consumption) * Population / 1000\n################################################################\n\nc_2020_pop_meat_exceeded_df = c_2020_pop_meat_df[c_2020_pop_meat_df['Meat Consumption per Capita'] > recommended_meat_weight].copy()\n\nc_2020_pop_meat_exceeded_df['Meat Overconsumption KPI (kg)'] = ((c_2020_pop_meat_exceeded_df['Meat Consumption per Capita'] - recommended_meat_weight) * c_2020_pop_meat_exceeded_df['Population'])\nc_2020_pop_meat_exceeded_df['Meat Overconsumption KPI'] = ((c_2020_pop_meat_exceeded_df['Meat Consumption per Capita'] - recommended_meat_weight) * c_2020_pop_meat_exceeded_df['Population'])/1000\nc_2020_pop_meat_exceeded_df = c_2020_pop_meat_exceeded_df.sort_values(by=['Meat Overconsumption KPI'], ascending=True)\n\nc_2020_pop_meat_exceeded_df\n","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"The ***Meat Overconsumption KPI*** quantifies the amount of meat overconsumption. It can be used to estimate the environmental impact of exceeding the meat consumption limit recommended by health experts. Furthermore, it can be used to estimate CO2 and water waste as a result of exceeding the limit. Here's the equation:\n\n$$ Meat Overconsumption KPI = \\frac{(M_{capita} - M_{recommended}) *  P_{city}} {1000} $$\n\nwhere $M_{capita}$ is the amount of the meat consumed per capita , $M_{recommended}$ is the recommended meat consumption, and $P_{city}$ is the population of the city. We divide by 1000 to convert from kg to tonnes. \n\nThis KPI computes the city-wide amount of meat consumed that is above the limit. For example, if the result is 100, it means that the population of the city collectively overconsumed meat equal to 100 tonnes of meat. The bar chart below indicates that Moscow has the highest meat overconsumption among the cities that provided information about meat consumption per capita. The amount of meat overconsumption in Moscow is 550735 tonnes of meat. Lima and Housten come in second and third place with 265022 and 115153 tonnes of meat."},{"metadata":{"_kg_hide-input":true,"_kg_hide-output":false,"trusted":true},"cell_type":"code","source":"# Draw Bar Chart Meat Overconsumption in Tonnes KPI\ndraw_bar_chart(df = c_2020_pop_meat_exceeded_df, \n               x = 'Meat Overconsumption KPI', \n               y= 'City', \n               chart_title = 'Meat Overconsumption in Tonnes KPI<br>(The Amount of Meat Overconsumed in the City)', \n               x_title = 'Meat Overconsumption (Tonnes)', \n               y_title = 'City', \n               texttemplate = '%{text:.2f}', \n               chart_height = 1000, \n               line_x = None, \n               line_text = None)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"Meat has the highest carbon footprint among other food groups. The table below shows the amount of CO2 emissions per 1 kg of meat. The information in this table was taken from [[15](#ref_15)]. \n\n| Meat Type| CO2 Emissions (kg) per 1 kg of meat |\n| :---     | :---      |\n| Lamb| 39.2|\n| Beef| 27|\n| Pork| 12.1|\n| Farmed Salmon| 11.9|\n| Turkey | 10.9|\n| Chicken| 6.9|\n| Canned Tuna| 6.1|\n| Average | 18.6 |\n\n<br>\n\nAssuming that a person consumes equal amounts of these meat types, we can estimate the amount of CO2 emissions in tonnes by multiplying the average CO2 emissions for the various meat types by the Meat Overconsumption KPI. The bar chart below shows the amount of CO2 emissions as a result of producing the over consumed meat. The CO2 emissions for meat overconsumption in Moscow is above 10 million tonnes. The CO2 emissions as a result of meat overconsumption in Lima and Houston is 5 million and 2.1 million, respectively."},{"metadata":{"_kg_hide-input":true,"_kg_hide-output":false,"trusted":true},"cell_type":"code","source":"# We can compute CO2 Emissions\n# According to: https://www.businessinsider.com.au/the-top-10-foods-with-the-biggest-environmental-footprint-2015-9\n# This is how much CO2 these meats produce:\n    # 1 kg of Lamb: 39.2 kg CO2\n    # 1 kg of Beef: 27 kg CO2\n    # 1 kg of Pork: 12.1 kg CO2\n    # 1 kg of Farmed Salmon: 11.9 kg CO2\n    # 1 kg of Turkey: 10.9 kg CO2\n    # 1 kg of Chicken: 6.9 kg CO2\n    # 1 kg of Canned Tuna: 6.1 kg CO2\n\n# Assuming that the population is eating equal amounts of each meat type:\n    # The Average Meat is: 18.6 kg CO2\n\nmeat_to_CO2 = 18.6\nc_2020_pop_meat_exceeded_df['Meat Overconsumption CO2 Emissions KPI'] = c_2020_pop_meat_exceeded_df['Meat Overconsumption KPI'] * meat_to_CO2\n\n# Draw Bar Chart Meat Overconsumption CO2 Emissions in Tonnes KPI\ndraw_bar_chart(df = c_2020_pop_meat_exceeded_df, \n               x = 'Meat Overconsumption CO2 Emissions KPI', \n               y= 'City', \n               chart_title = 'Meat Overconsumption CO2 Emissions in Tonnes KPI', \n               x_title = 'Meat Overconsumption CO2 Emissions (Tonnes)', \n               y_title = 'City', \n               texttemplate = '%{text:.2s}', \n               chart_height = 1000, \n               line_x = None, \n               line_text = None)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"Meat overconsumption is also a major challenge to water security. The table below shows the amount of water in liters that is needed to produce 1 kg of meat. The information in this table was taken from [[16](#ref_16)]. \n\n| Meat Type| Water Needed (liters) per 1 kg of meat |\n| :---     | :---      |\n| Beef| 15,415|\n| Lamb| 10,412|\n| Pork| 5,988|\n| Chicken| 4,325|\n| Average| 9,035|\n\n<br>\n\nIn a similar manner, we can multiply the average amount of water needed to produce 1 kg of meat with the Meat Overconsumption KPI to get the amount of water resulting from exceeding the recommended meat limit. In order to visualize the magnitude of the water that went into producing the over consumed meat, we can estimate the amount of water that one person consumes per year. According to the U.S. Geological Survey [[17](#ref_17)], one person consumes 36500 liters per year, which is equivalent to 36.5 Cubic meters per person. We can get the city-wide residential consumption by multiplying this number by the population. \n\nThe chart below shows the meat overconsumption water usage along with the estimated residential water usage in cubic meters. Meat overconsumption exceeds the residential water usage for each city. For instance, in Moscow, meat overconsumption is responsible for 5 Billion cubic meters while residential water usage is far less (462 millions of cubic meters)."},{"metadata":{"_kg_hide-input":true,"trusted":true},"cell_type":"code","source":"# We can compute Water Cost of Meat \n\n# source: https://www.theguardian.com/news/datablog/2013/jan/10/how-much-water-food-production-waste\n# Here's how much water 1 kg of meat needs:\n    # 1 kg of Beef = 15,415 liters\n    # 1 kg of Sheep Meat = 10,412  liters\n    # 1 kg of Pork = 5,988 liters\n    # 1 kg of Chicken meat = 4,325  liters\n\n# Assuming that the population is eating equal amounts of each meat type:\n    # The average water used is 9035 liters for 1 kg of meat.\n\n# Estimating The Annual Water Consumption by 1 person\n# According to: https://www.usgs.gov/special-topic/water-science-school/science/water-qa-how-much-water-do-i-use-home-each-day?qt-science_center_objects=0#qt-science_center_objects\n    # The daily use per person is 80-100 liters per day. We will take the upper limit (100 liters per day) .\n    # 100 litres * 365 days = 36500 litres per year = 36.5 Cubic Meters\n\nmeat_to_water = 9035 # liters\nwater_usage_by_person = 36.5# Cubic Water\nc_2020_pop_meat_exceeded_df['Meat Overconsumption Water Used KPI'] = c_2020_pop_meat_exceeded_df['Meat Overconsumption KPI'] * meat_to_water\nc_2020_pop_meat_exceeded_df['Estimated Water Usage (Cubic Meters)'] = c_2020_pop_meat_exceeded_df['Population'] * water_usage_by_person\n\n# Draw Bar Chart Meat Overconsumption CO2 Emissions in Tonnes KPI\n# draw_bar_chart(df = c_2020_pop_meat_exceeded_df, \n#                x = 'Meat Overconsumption Water Used KPI', \n#                y= 'City', \n#                chart_title = 'Water Used to Produce the Overconsumed Meat in Cubic Meters KPI', \n#                x_title = 'Water Used to Produce the Overconsumed Meat (Cubic Meters)', \n#                y_title = 'City', \n#                texttemplate = '%{text:.2s}', \n#                chart_height = 1000, \n#                line_x = None, \n#                line_text = None)\n\n# Plot the Bar Chart\ndf = c_2020_pop_meat_exceeded_df[-15:]# Show 20 rows only for easier visibility\nx, y = 'Meat Overconsumption Water Used KPI', 'City'\nx2, y2 = 'Estimated Water Usage (Cubic Meters)', 'City'\nchart_title = 'Water Used to Produce the Overconsumed Meat in Cubic Meters KPI'\nx_title, y_title = 'Water Used (Cubic Meters)', 'City'\ntexttemplate = '%{text:.4s}'\nchart_height = 1000\n\ntext = [str(round(i/1000000, 2))+'M' if i<1000000000 else str(round(i/1000000000, 2))+'B' for i in df[x].values ]\n\nbar_chart = go.Bar(x=df[x], y=df[y], orientation='h', text=text, textposition='auto', name = 'Meat Overconsumption<br>Water Usage')\nbar2_chart = go.Bar(x=df[x2], y=df[y2], orientation='h', text=df[x2], textposition='auto', name = 'Residential Water <br> Usage', texttemplate=texttemplate)\nfig = make_subplots(specs=[[{\"secondary_y\": True}]], print_grid=False)\nfig.add_trace(bar2_chart, 1, 1, secondary_y=False)\nfig.add_trace(bar_chart, 1, 1, secondary_y=False)\nfig.update_layout(title=chart_title, height=chart_height, xaxis=dict(title=x_title), yaxis = dict(title=y_title), yaxis2= dict(fixedrange= True, visible= False), showlegend=True)\nfig.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"To sum up, in addition to the health risks of exceeding the meat consumption limit, there's a significant environmental cost to meat overconsumption.\n\n# Summary & Conclusion\n<a id=\"sec_conclusion\"></a>\n\nIn this notebook, we studied the social and environmental cost of food waste, food insecurity, and meat overconsumption. We introduced the Healthy Diet dataset, which includes information about the different food groups that make up a healthy diet. We used it to study food waste and meat overconsumption. As a result, we introduced three KPIs: the Food Waste Per Capita Nutrition Loss KPI, the Food Loss Per Food-Insecure Population KPI, and the Meat Overconsumption KPI. We used the Meat Overconsumption KPI to study the CO2 emissions and water challenges related to Meat Overconsumption. The table below presents a summary of the three KPIs:\n\n| KPI| Type | Description | Equation | Example | \n| :---     | :---      | :---      | :---      | :---      |\n| Food Waste Per Capita Nutrition Loss| Social Vulnerability KPI + Environmental | This KPI measures the per capita nutrition loss expressed in terms of the number of people who could have met their nutritional needs if the food was not wasted. It is ideal for any city regardless of the size of the food-insecure population | $$ Food Waste Per Capita Nutrition Loss = \\frac {W_{capita} - S_{capita}} {D} $$ | If the result is 2, it means that the nutrition loss is equal to feeding to 2 people for 1 year. |\n| Food Loss Per Food-Insecure Population | Social Vulnerability KPI + Environmental | This KPI measures the average amount of food in kilograms that a food-insecure person could have received if the food was not wasted. It is good for cities with small food-insecure populations as it can incentivize the city to work harder on closing the gap between food waste and insecurity. | $$ Food Loss Per Food Insecure Population KPI = 1000 * \\frac {W_{city} - S_{city}} {P_{foodinsecure} * P_{city}} $$ | If the result is 10, it means that one person from the food-insecure population could have potentially received 10 kilograms of food. |\n| Meat Overconsumption | Environmental KPI | This KPI measures the magnitude of meat overconsumption. In addition, it can be used to estimate the environmental impact of exceeding the meat consumption limit recommended by health experts. Furthermore, it can be used to estimate CO2 and water waste as a result of exceeding the limit. | $$ Meat Overconsumption KPI = \\frac{(M_{capita} - M_{recommended}) *  P_{city}} {1000} $$ | If the result is 100, it means that the population of the city collectively overconsumed meat equal to 100 tonnes of meat.  |\n\n\n\n<br>\n<br>\n\n\n\n\nThank you very much for taking the time to read this notebook. "},{"metadata":{},"cell_type":"markdown","source":"# References\n<a id=\"sec_references\"></a>\n* [1] <a id=\"ref_1\"></a> Household food insecurity in Canada: Overview - https://www.canada.ca/en/health-canada/services/food-nutrition/food-nutrition-surveillance/health-nutrition-surveys/canadian-community-health-survey-cchs/household-food-insecurity-canada-overview.html\n* [2] <a id=\"ref_2\"></a> Food Insecurity - https://www.healthypeople.gov/2020/topics-objectives/topic/social-determinants-health/interventions-resources/food-insecurity\n* [3] <a id=\"ref_3\"></a> Hunger and Undernourishment - https://ourworldindata.org/hunger-and-undernourishment\n* [4] <a id=\"ref_4\"></a> Eyeing up intake: an Insight on overconsumption and diet - https://www.foodsecurity.ac.uk/blog/eyeing-up-intake-an-insight-on-overconsumption-and-diet/\n* [5] <a id=\"ref_5\"></a> Fifth of world's food lost to over-eating and waste, study finds - https://phys.org/news/2017-02-world-food-lost-over-eating.html\n* [6] <a id=\"ref_6\"></a> For Your Health - https://endindustrialmeat.org/ten-reasons-to-opt-out/for-our-health/\n* [7] <a id=\"ref_7\"></a> Environmental Impact of Meat Consumption - https://cases.open.ubc.ca/environmental-impact-of-meat-consumption/\n* [8] <a id=\"ref_8\"></a> The Problem of Food Waste - https://foodprint.org/issues/the-problem-of-food-waste/\n* [9] <a id=\"ref_9\"></a> Healthy Diet Breakdown - https://www.kaggle.com/abdulwahabkabani/healthy-diet-breakdown\n* [10] <a id=\"ref_10\"></a> Suggested Servings from Each Food Group - https://www.heart.org/en/healthy-living/healthy-eating/eat-smart/nutrition-basics/suggested-servings-from-each-food-group\n* [11] <a id=\"ref_11\"></a> Tragedy of the Commons - https://en.wikipedia.org/wiki/Tragedy_of_the_commons\n* [12] <a id=\"ref_12\"></a> The carbon footprint - https://toogoodtogo.org/en/movement/knowledge/the-carbon-footprint\n* [13] <a id=\"ref_13\"></a> 21 Inspiring Initiatives Working to Reduce Food Waste Around the World - https://foodtank.com/news/2015/01/twenty-one-inspiring-initiatives-working-to-reduce-food-waste-around-the-wo/\n* [14] <a id=\"ref_14\"></a> 3 Benefits of Eating Meat - https://www.medicaldaily.com/3-benefits-eating-meat-234798\n* [15] <a id=\"ref_15\"></a> The top 10 foods with the biggest environmental footprint - https://www.businessinsider.com.au/the-top-10-foods-with-the-biggest-environmental-footprint-2015-9\n* [16] <a id=\"ref_16\"></a> How Much Water Food Production Waste - https://www.theguardian.com/news/datablog/2013/jan/10/how-much-water-food-production-waste\n* [17] <a id=\"ref_17\"></a> Water Q&A: How much water do I use at home each day? - https://www.usgs.gov/special-topic/water-science-school/science/water-qa-how-much-water-do-i-use-home-each-day?qt-science_center_objects=0#qt-science_center_objects"}],"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat":4,"nbformat_minor":4}