{"cells":[{"metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true},"cell_type":"code","source":"# standard libs\nimport os\nimport pandas as pd\nimport numpy as np\nimport matplotlib.pyplot as plt\nimport re\nimport json\nimport zipfile\nfrom sklearn.cluster import KMeans\n\n# plotting libs\nimport seaborn as sns","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"# Corporation Participation as KPI\n\n1. Industry Breakdown (for participating Corporations)\nOver half of corporations that participted in the CDP survey in 2020 belong to the manufacturing industry and the services industry. Considering the abundance of consumer products- these corporations should be sampled frequently for climate change awareness. "},{"metadata":{"_uuid":"d629ff2d2480ee46fbb7e2d37f6b5fab8052498a","collapsed":true,"_cell_guid":"79c7e3d0-c299-4dcb-8224-4455121ee9b0","trusted":false},"cell_type":"code","source":"##import 2020 data\ncorporate_2020_climate_change=pd.read_csv('../input/cdp-unlocking-climate-solutions/Corporations/Corporations Responses/Climate Change/2020_Full_Climate_Change_Dataset.csv')\ncorporate_2019_climate_change=pd.read_csv('../input/cdp-unlocking-climate-solutions/Corporations/Corporations Responses/Climate Change/2019_Full_Climate_Change_Dataset.csv')\ncorporate_2020_water=pd.read_csv('../input/cdp-unlocking-climate-solutions/Corporations/Corporations Responses/Water Security/2020_Full_Water_Security_Dataset.csv')\ncity_2020_responses=pd.read_csv('../input/cdp-unlocking-climate-solutions/Cities/Cities Responses/2020_Full_Cities_Dataset.csv')\n\n# ##import Disclosure data\ncorp_2020_disclosure=pd.read_csv('../input/cdp-unlocking-climate-solutions/Corporations/Corporations Disclosing/Climate Change/2020_Corporates_Disclosing_to_CDP_Climate_Change.csv')\ncorp_2019_disclosure=pd.read_csv('../input/cdp-unlocking-climate-solutions/Corporations/Corporations Disclosing/Climate Change/2019_Corporates_Disclosing_to_CDP_Climate_Change.csv')\ncorp_2018_disclosure=pd.read_csv('../input/cdp-unlocking-climate-solutions/Corporations/Corporations Disclosing/Climate Change/2018_Corporates_Disclosing_to_CDP_Climate_Change.csv')\n","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"##various sectors of the questionaire responders \ncorp_2020_disclosure['primary_industry'].value_counts().plot.pie(pctdistance=0.7,autopct='%.2f%%',figsize=(6,6),labels=None)\nplt.title(\"Corporations Disclosing Climate Change Surveys by Industry\",fontsize=17,ha='left')\nplt.legend(labels=corp_2020_disclosure['primary_industry'].value_counts().index, loc=\"best\",bbox_to_anchor=(1, 0.25, 0.5, 0.5))\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":""},{"metadata":{},"cell_type":"markdown","source":"2.Corporation awareness of Climate Change Risks+Opportunities over time: What % of corporations recognize risks and opporunities (in 2019 vs. 2020)? "},{"metadata":{"trusted":true},"cell_type":"code","source":"corp_2019_risks=corporate_2019_climate_change[(corporate_2019_climate_change['question_number']==\"C2.3\")&(corporate_2019_climate_change['row_number']==0)]\ncorp_2019_opp=corporate_2019_climate_change[(corporate_2019_climate_change['question_number']==\"C2.4\")&(corporate_2019_climate_change['row_number']==0)]\n\n\nfig = plt.figure(figsize=(15,9))\nplt.suptitle(\"Corporate Sentiment to Climate Change 2019\",fontsize=18)\nax1 = fig.add_subplot(221)\nax2 = fig.add_subplot(222)\n\n\ncorp_2019_risks['response_value'].value_counts().plot.pie(pctdistance=0.7,autopct='%.2f%%', labels=corp_2019_risks.index, ax=ax1)\nax1.title.set_text(\"Have you identified any inherent climate-related risks...?\")\nax1.legend(labels=corp_2019_risks['response_value'].value_counts().index, loc=\"best\",bbox_to_anchor=(1, 0.25, 0.5, 0.5))\n\n\ncorp_2019_opp['response_value'].value_counts().plot.pie(pctdistance=0.7,autopct='%.2f%%', labels=corp_2019_opp.index, ax=ax2)\nax2.title.set_text(\"Have you identified any climate-related opportunities...?\")              \nax2.legend(labels=corp_2019_opp['response_value'].value_counts().index, loc=\"best\",bbox_to_anchor=(1, 0.25, 0.5, 0.5))\n\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"corp_2020_risks=corporate_2020_climate_change[(corporate_2020_climate_change['question_number']==\"C2.3\")&(corporate_2020_climate_change['row_number']==0)]\ncorp_2020_opp=corporate_2020_climate_change[(corporate_2020_climate_change['question_number']==\"C2.4\")&(corporate_2020_climate_change['row_number']==0)]\n\n\nfig = plt.figure(figsize=(15,9))\nplt.suptitle(\"Corporate Sentiment to Climate Change 2020\",fontsize=18)\nax1 = fig.add_subplot(221)\nax2 = fig.add_subplot(222)\n\n\ncorp_2020_risks['response_value'].value_counts().plot.pie(pctdistance=0.7,autopct='%.2f%%', labels=corp_2019_risks.index, ax=ax1)\nax1.title.set_text(\"Have you identified any inherent climate-related risks...?\")\nax1.legend(labels=corp_2019_risks['response_value'].value_counts().index, loc=\"best\",bbox_to_anchor=(1, 0.25, 0.5, 0.5))\n\n\ncorp_2020_opp['response_value'].value_counts().plot.pie(pctdistance=0.7,autopct='%.2f%%', labels=corp_2019_opp.index, ax=ax2)\nax2.title.set_text(\"Have you identified any climate-related opportunities...?\")              \nax2.legend(labels=corp_2019_opp['response_value'].value_counts().index, loc=\"best\",bbox_to_anchor=(1, 0.25, 0.5, 0.5))\n\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"3. Participation: How many corporations participated in the survey each year? ****"},{"metadata":{"trusted":true},"cell_type":"code","source":"##basic plots to visualize participation rates- count of increased corp participants YoY and count of corp dropouts YoY \nfrom functools import reduce\n\n\ncorp_2020= corp_2020_disclosure[['survey_year','account_number']]\ncorp_2019= corp_2019_disclosure[['survey_year','account_number']]\ncorp_2018= corp_2018_disclosure[['survey_year','account_number']]\n\ncorp_participants = pd.merge(pd.merge(corp_2020,corp_2019, how='left',on='account_number'),corp_2018, how='left',on='account_number')\ncorp_participants=corp_participants.rename(columns={\"survey_year_x\": \"2020\", \"survey_year_y\": \"2019\", \"survey_year\": \"2018\"})\ncorp_dropouts = pd.merge(pd.merge(corp_2018,corp_2019, how='left',on='account_number'),corp_2020, how='left',on='account_number')\ncorp_dropouts=corp_dropouts.rename(columns={\"survey_year_x\": \"2018\", \"survey_year_y\": \"2019\", \"survey_year\": \"2020\"})\n\ndropout_rates= corp_dropouts.groupby(['2018'])['2018','2019','2020'].count()\nparticipation_rates=corp_participants.groupby(['2020'])['2018','2019','2020'].count()\n\nprint(participation_rates)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"4. Drop out Rate: How many corporations have dropped out from 2018? "},{"metadata":{"trusted":true},"cell_type":"code","source":"print(dropout_rates)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"**Regression Analysis **\n\nHow have corporations responded to the question \"Did you have emissions reduction initiatives that were active within the reporting year? Note that this can include those in the planning and/or implementation phases.\" \n\nFirst contributing factors I thought to look for are their estimated cost savings for both 2019 and 2020. "},{"metadata":{"trusted":true},"cell_type":"code","source":"##log regressions\ncorp_active_2020=corporate_2020_climate_change[(corporate_2020_climate_change['question_number']==\"C4.3\")&(corporate_2020_climate_change['row_number']==0)]\ncorp_active_2020=corp_active_2020[['account_number','response_value']].dropna()\ncorp_active_2020['response_value']=np.where(corp_active_2020['response_value']==\"Yes\",1,0)\n\ncorp_2019est_savings=corporate_2019_climate_change[corporate_2019_climate_change['question_number']==\"C4.3a\"]\ncorp_2019est=corp_2019est_savings[['account_number','response_value']]\n\ncorp_2020est_savings=corporate_2020_climate_change[corporate_2020_climate_change['question_number']==\"C4.3a\"]\ncorp_2020est=corp_2020est_savings[['account_number','response_value']]\ncorp_est_savings= pd.merge(corp_2020est, corp_2019est, how=\"left\", on=\"account_number\" ).fillna(0)\ncorp_est_savings=corp_est_savings.rename(columns={\"response_value_x\": \"2020_est_savings\", \"response_value_y\": \"2019_est_savings\"})\ncorp_est_savings['2020_est_savings']=corp_est_savings['2020_est_savings'].astype(float)\ncorp_est_savings['2019_est_savings']=corp_est_savings['2019_est_savings'].astype(float)\n\ndf= pd.merge(corp_active_2020, corp_est_savings, how=\"left\", on=\"account_number\" ).fillna(0)\n# df= df.groupby['account_number','response_value]['2020_est_savings','2019_est_savings'].sum()\n\nimport statsmodels.api as sm\n\nX=df[['2020_est_savings','2019_est_savings']]\ny=df['response_value']\n\n\n# Note the difference in argument order\n# Note the difference in argument order\nest = sm.OLS(y, X).fit()\npredictions = est.predict(X) # make the predictions by the model\n\n# Print out the statistics\nest.summary()\n","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"Using only these two varibles produces significance but isn't particularly helpful. It may be useful to add more features to the model. We will add the industry of coporations, whether they have identified risks and opportunities regarding climate change and whether or not they participated in the survey in order to estimate whether these contribute to the corporation's willingness to participate."},{"metadata":{"trusted":true},"cell_type":"code","source":"## collecting intention data and merging to disclosure details to find features that would indicate that a corporation is willing to set targets \n\ncorp_active_stats=corporate_2020_climate_change[(corporate_2020_climate_change['question_number']==\"C4.3\")&(corporate_2020_climate_change['row_number']==0)]\ncorp_active= pd.merge(corp_active_stats, corp_2020_disclosure, how=\"left\", on=\"account_number\" )\ncorp_participants_acct=corp_participants.groupby(['account_number'])['2018','2019','2020'].count()\ncorp_active= pd.merge(corp_active, corp_participants_acct, how=\"left\", on=\"account_number\" )\ncorp_active=corp_active[['account_number','2018','2019','2020']]\n# corp_active= pd.get_dummies(corp_active, columns=['primary_industry'])\n\ncorp_2020_risk_values=corp_2020_risks[['account_number','response_value']].dropna()\ncorp_2020_opp_values=corp_2020_opp[['account_number','response_value']].dropna()\ncorp_2020_risk_values=corp_2020_risk_values.rename(columns={\"response_value\": \"Corp has ID'd risks\"})\ncorp_2020_opp_values=corp_2020_opp_values.rename(columns={\"response_value\": \"Corp has ID'd opportunities\"})\ncorp_2020_risk_values=pd.get_dummies(corp_2020_risk_values).dropna()\ncorp_2020_opp_values=pd.get_dummies(corp_2020_opp_values).dropna()\n\ncorp_responses=pd.merge(corp_2020_risk_values, corp_2020_opp_values, how=\"left\", on=\"account_number\" )\n\ndf4= pd.merge(corp_active_2020, corp_responses,how=\"left\", on=\"account_number\").dropna()\ndf5= pd.merge(df4, corp_active, how=\"left\", on=\"account_number\" )\n\nX=df5.iloc[:,2:22]\ny=df5.iloc[:,[1]]\n\n\n# Note the difference in argument order\n# Note the difference in argument order\nest = sm.OLS(y, X).fit()\npredictions = est.predict(X) # make the predictions by the model\n\n# Print out the statistics\nest.summary()\n","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"This model implies that there are too many issues with mutlicolinearity. Trying another model given this set of data would not prove very helpful. \n\nSome future steps we could take would be to try some of the other questions from the survey that we could use to better understand what compells corporations to set climate change risks. \n\nWe should also incorporate city data to better understand the opportunity for corporations to work within a city's emission target. Moreover, we could utilize corporation initatives to employ workers within a city for climate change/water work. "}],"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}