{"cells":[{"metadata":{},"cell_type":"markdown","source":"# Measuring the Progress Toward Preventing Climate Change"},{"metadata":{},"cell_type":"markdown","source":"Climate change is a continuous and emerging problem in today's world. It has been proven through studies that climate change is most likely caused by human, or anthropogenic. To provide solutions for climate change, data science can be a useful weapon to find insights and discover ways to prevent climate change."},{"metadata":{},"cell_type":"markdown","source":"In this notebook, we will investigate 3 different survey responses that are publicly available: 1) corporate climate change disclosures, 2) corporate water security disclosures, and 3) disclosures from cities."},{"metadata":{},"cell_type":"markdown","source":"First, we will read and combine the climate change data into one DataFrame"},{"metadata":{"trusted":true},"cell_type":"code","source":"# Import Libraries\nimport pandas as pd\nimport numpy as np\nimport matplotlib.pyplot as plt\nimport seaborn as sns\nimport plotly","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"## Cleaning and Exploratory Data Analysis (EDA)"},{"metadata":{"trusted":true},"cell_type":"code","source":"# See first 5 rows of cities 2020 data\ncities_2020 = pd.read_csv(\"../input/cdp-unlocking-climate-solutions/Cities/Cities Responses/2018_Full_Cities_Dataset.csv\")\ncities_2020.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"# Read and append all city responses data into one DataFrame\ncities_2019 = pd.read_csv(\"../input/cdp-unlocking-climate-solutions/Cities/Cities Responses/2019_Full_Cities_Dataset.csv\")\ncities_2018 = pd.read_csv(\"../input/cdp-unlocking-climate-solutions/Cities/Cities Responses/2018_Full_Cities_Dataset.csv\")\n\ncities = cities_2020.append(cities_2019)\ncities = cities.append(cities_2018)\ncities.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"# See info about data\ncities.info()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"We can notice from the information that there are some string columns which are incomplete. We also notice there are not a lot of responses compared to questions. We will filter out any rows without responses."},{"metadata":{"trusted":true},"cell_type":"code","source":"# Filter out questions with no responses and fill other rows with \"No response\"\ncities = cities[cities['Response Answer'].notna()]\ncities[['Parent Section', 'Column Name', 'Row Name', 'Comments', 'File Name']] = cities[['Parent Section', 'Column Name', 'Row Name', 'Comments', 'File Name']].fillna(\"No response\")\ncities.info()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"Now, we will investigate the questions that were asked and responses to see which ones could be useful for defining KPIs."},{"metadata":{"trusted":true},"cell_type":"code","source":"cities_questions = cities['Question Name'].unique()\nprint(cities_questions)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"cities_responses = cities['Response Answer'].unique()\nprint(cities_responses)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"Let us count the number of questions with responses to see which is the most common question. We can then use this to define our KPI since we want the KPI to be representative of the views and perspectives of the sample."},{"metadata":{"trusted":true},"cell_type":"code","source":"cities_no_questions = cities.groupby('Question Number').count()\n\n# We will visualize the top 10 questions as a bar chart\ncities_no_questions = cities_no_questions.sort_values('Response Answer', ascending=False)\ncities_no_questions\n\nfig, ax = plt.subplots(figsize=(15, 10))\nplt.bar(cities_no_questions.index[:10], cities_no_questions['Response Answer'].iloc[:10])\nplt.ylabel(\"Number of Responses\", fontsize=18)\nplt.xlabel(\"Question Number\", fontsize=18)\nplt.title(\"Number of Reponses for Top 10 Question Numbers\", fontsize=24)\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"We can see that the top 5 questions have over 1,500 responses. Let us see what questions these question numbers correspond to."},{"metadata":{"trusted":true},"cell_type":"code","source":"top_4_qs = cities.loc[cities['Question Number'].isin(['2.1', '5.4', '2.2a', '3.0']), ['Question Number', 'Question Name']].copy()\ntop_4_qs = top_4_qs.drop_duplicates()\ntop_4_qs","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"In the code cell output, we see that there is not a one-to-one relationship between the Question Number and Question Name."},{"metadata":{},"cell_type":"markdown","source":"## Defining KPIs\n\nAccording to Klipfolio (https://www.klipfolio.com/resources/articles/what-is-a-key-performance-indicator#:~:text=Key%20Performance%20Indicator%20(KPI)%20Definition,their%20success%20at%20reaching%20targets.), KPIs are measurable values that demonstrate how effectively an organization is achieving key objectives.\n\nWe can define an environmental KPI to have a maximum value of 100 and composed of 4 categories: energy usage, water usage, waste generated, and greenhouse gases generated. A score of 100 means that a city or organization used a lot of resources or generated a lot of waste and greenhouse gases, therefore a score of 0 should be the target.\n\nTo quantify the responses, we can use natural language processing (NLP) to score each city and corporation based on their performance in the 4 categories."},{"metadata":{"trusted":true},"cell_type":"code","source":"","execution_count":null,"outputs":[]}],"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}