diff --git a/aggregated-results/sdg-profiles-statistics.ipynb b/aggregated-results/sdg-profiles-statistics.ipynb index 009395fd33a818e1e945b52113edc0ad9639678a..83e6aadefbd922bf5de36c0d6416cd1a386fac22 100644 --- a/aggregated-results/sdg-profiles-statistics.ipynb +++ b/aggregated-results/sdg-profiles-statistics.ipynb @@ -397,7 +397,7 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 51, "metadata": {}, "outputs": [ { @@ -421,123 +421,147 @@ " <thead>\n", " <tr style=\"text-align: right;\">\n", " <th></th>\n", - " <th>0</th>\n", + " <th>SDG-count</th>\n", + " <th>SDG-code</th>\n", " </tr>\n", " </thead>\n", " <tbody>\n", " <tr>\n", " <th>SDG-01</th>\n", " <td>8</td>\n", + " <td>SDG-01</td>\n", " </tr>\n", " <tr>\n", " <th>SDG-02</th>\n", " <td>12</td>\n", + " <td>SDG-02</td>\n", " </tr>\n", " <tr>\n", " <th>SDG-03</th>\n", " <td>23</td>\n", + " <td>SDG-03</td>\n", " </tr>\n", " <tr>\n", " <th>SDG-04</th>\n", " <td>172</td>\n", + " <td>SDG-04</td>\n", " </tr>\n", " <tr>\n", " <th>SDG-05</th>\n", " <td>70</td>\n", + " <td>SDG-05</td>\n", " </tr>\n", " <tr>\n", " <th>SDG-06</th>\n", " <td>12</td>\n", + " <td>SDG-06</td>\n", " </tr>\n", " <tr>\n", " <th>SDG-07</th>\n", " <td>30</td>\n", + " <td>SDG-07</td>\n", " </tr>\n", " <tr>\n", " <th>SDG-08</th>\n", " <td>63</td>\n", + " <td>SDG-08</td>\n", " </tr>\n", " <tr>\n", " <th>SDG-09</th>\n", " <td>148</td>\n", + " <td>SDG-09</td>\n", " </tr>\n", " <tr>\n", " <th>SDG-10</th>\n", " <td>22</td>\n", + " <td>SDG-10</td>\n", " </tr>\n", " <tr>\n", " <th>SDG-11</th>\n", " <td>79</td>\n", + " <td>SDG-11</td>\n", " </tr>\n", " <tr>\n", " <th>SDG-12</th>\n", " <td>96</td>\n", + " <td>SDG-12</td>\n", " </tr>\n", " <tr>\n", " <th>SDG-13</th>\n", " <td>24</td>\n", + " <td>SDG-13</td>\n", " </tr>\n", " <tr>\n", " <th>SDG-14</th>\n", " <td>5</td>\n", + " <td>SDG-14</td>\n", " </tr>\n", " <tr>\n", " <th>SDG-15</th>\n", " <td>16</td>\n", + " <td>SDG-15</td>\n", " </tr>\n", " <tr>\n", " <th>SDG-16</th>\n", " <td>2</td>\n", + " <td>SDG-16</td>\n", " </tr>\n", " <tr>\n", " <th>SDG-17</th>\n", " <td>35</td>\n", + " <td>SDG-17</td>\n", " </tr>\n", " </tbody>\n", "</table>\n", "</div>" ], "text/plain": [ - " 0\n", - "SDG-01 8\n", - "SDG-02 12\n", - "SDG-03 23\n", - "SDG-04 172\n", - "SDG-05 70\n", - "SDG-06 12\n", - "SDG-07 30\n", - "SDG-08 63\n", - "SDG-09 148\n", - "SDG-10 22\n", - "SDG-11 79\n", - "SDG-12 96\n", - "SDG-13 24\n", - "SDG-14 5\n", - "SDG-15 16\n", - "SDG-16 2\n", - "SDG-17 35" + " SDG-count SDG-code\n", + "SDG-01 8 SDG-01\n", + "SDG-02 12 SDG-02\n", + "SDG-03 23 SDG-03\n", + "SDG-04 172 SDG-04\n", + "SDG-05 70 SDG-05\n", + "SDG-06 12 SDG-06\n", + "SDG-07 30 SDG-07\n", + "SDG-08 63 SDG-08\n", + "SDG-09 148 SDG-09\n", + "SDG-10 22 SDG-10\n", + "SDG-11 79 SDG-11\n", + "SDG-12 96 SDG-12\n", + "SDG-13 24 SDG-13\n", + "SDG-14 5 SDG-14\n", + "SDG-15 16 SDG-15\n", + "SDG-16 2 SDG-16\n", + "SDG-17 35 SDG-17" ] }, - "execution_count": 20, + "execution_count": 51, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# select rows with status = 'green' and columns sdg1-17\n", - "# create list of sdg column names\n", + "\n", "sdgs = []\n", "for s in range(17):\n", " sdgs = sdgs + [\"SDG-\" + f'{(s+1):02d}']\n", "selprofiles = profiles[profiles['status'] == 'green'][sdgs] # select rows flagged 'green' and columns SDG1-17\n", + "\n", + "# count SDG 1-17 occurences (to series)\n", "selseries = selprofiles.count() # create series with sdg counts 1-17\n", + "\n", + "# convert series to dataframe\n", "mytable = selseries.to_frame() # convert series to frame\n", + "mytable = mytable.rename(columns={0:'SDG-count'}) # rename column to 'SDG-count'\n", + "mytable['SDG-code'] = mytable.index\n", "mytable.head(20)" ] }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 55, "metadata": {}, "outputs": [ { @@ -546,18 +570,189 @@ "text": [ "<class 'pandas.core.frame.DataFrame'>\n", "Index: 17 entries, SDG-01 to SDG-17\n", - "Data columns (total 1 columns):\n", - " # Column Non-Null Count Dtype\n", - "--- ------ -------------- -----\n", - " 0 0 17 non-null int64\n", - "dtypes: int64(1)\n", - "memory usage: 204.0+ bytes\n" + "Data columns (total 2 columns):\n", + " # Column Non-Null Count Dtype \n", + "--- ------ -------------- ----- \n", + " 0 SDG-count 17 non-null int64 \n", + " 1 SDG-code 17 non-null object\n", + "dtypes: int64(1), object(1)\n", + "memory usage: 272.0+ bytes\n" ] } ], "source": [ - "seltable = selseries.to_frame()\n", - "seltable.info()\n" + "mytable.info()\n" + ] + }, + { + "cell_type": "code", + "execution_count": 56, + "metadata": {}, + "outputs": [ + { + "ename": "KeyError", + "evalue": "'SDG-code'", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mKeyError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m<ipython-input-56-09d567263d0a>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 7\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 8\u001b[0m \u001b[0mmytable\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mshape\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 9\u001b[0;31m \u001b[0mmytable\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mpd\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmerge\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmytable\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0msdgicons\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mhow\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m\"left\"\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mon\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m\"SDG-code\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 10\u001b[0m \u001b[0mmytable\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mshape\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/usr/local/lib/python3.7/dist-packages/pandas/core/reshape/merge.py\u001b[0m in \u001b[0;36mmerge\u001b[0;34m(left, right, how, on, left_on, right_on, left_index, right_index, sort, suffixes, copy, indicator, validate)\u001b[0m\n\u001b[1;32m 85\u001b[0m \u001b[0mcopy\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mcopy\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 86\u001b[0m \u001b[0mindicator\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mindicator\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 87\u001b[0;31m \u001b[0mvalidate\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mvalidate\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 88\u001b[0m )\n\u001b[1;32m 89\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mop\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_result\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/usr/local/lib/python3.7/dist-packages/pandas/core/reshape/merge.py\u001b[0m in \u001b[0;36m__init__\u001b[0;34m(self, left, right, how, on, left_on, right_on, axis, left_index, right_index, sort, suffixes, copy, indicator, validate)\u001b[0m\n\u001b[1;32m 666\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mright_join_keys\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 667\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mjoin_names\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 668\u001b[0;31m ) = self._get_merge_keys()\n\u001b[0m\u001b[1;32m 669\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 670\u001b[0m \u001b[0;31m# validate the merge keys dtypes. We may need to coerce\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/usr/local/lib/python3.7/dist-packages/pandas/core/reshape/merge.py\u001b[0m in \u001b[0;36m_get_merge_keys\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 1031\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0mis_rkey\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mrk\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1032\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mrk\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1033\u001b[0;31m \u001b[0mright_keys\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mappend\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mright\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_get_label_or_level_values\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mrk\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1034\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1035\u001b[0m \u001b[0;31m# work-around for merge_asof(right_index=True)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/usr/local/lib/python3.7/dist-packages/pandas/core/generic.py\u001b[0m in \u001b[0;36m_get_label_or_level_values\u001b[0;34m(self, key, axis)\u001b[0m\n\u001b[1;32m 1682\u001b[0m \u001b[0mvalues\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0maxes\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0maxis\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_level_values\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_values\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1683\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1684\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mKeyError\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1685\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1686\u001b[0m \u001b[0;31m# Check for duplicates\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;31mKeyError\u001b[0m: 'SDG-code'" + ] + } + ], + "source": [ + "# Get data from gitlab.fabcloud.org\n", + "# Read XLSX sheet with sdg icon codes \n", + "url = 'https://gitlab.fabcloud.org/fl-management/fl-sdgs/sdg-workshop/-/raw/master/'\n", + "url = url + 'local-workshop-sources/sdg-icon-translator.xlsx' \n", + "timestamp = datetime.datetime.utcnow()\n", + "sdgicons = pd.read_excel(url, 'en', index_col=0)\n", + "\n", + "mytable.shape\n", + "mytable = pd.merge(mytable, sdgicons, how=\"left\", on=\"SDG-code\")\n", + "mytable.shape" + ] + }, + { + "cell_type": "code", + "execution_count": 49, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "<div>\n", + "<style scoped>\n", + " .dataframe tbody tr th:only-of-type {\n", + " vertical-align: middle;\n", + " }\n", + "\n", + " .dataframe tbody tr th {\n", + " vertical-align: top;\n", + " }\n", + "\n", + " .dataframe thead th {\n", + " text-align: right;\n", + " }\n", + "</style>\n", + "<table border=\"1\" class=\"dataframe\">\n", + " <thead>\n", + " <tr style=\"text-align: right;\">\n", + " <th></th>\n", + " <th>icon-text</th>\n", + " </tr>\n", + " <tr>\n", + " <th>code</th>\n", + " <th></th>\n", + " </tr>\n", + " </thead>\n", + " <tbody>\n", + " <tr>\n", + " <th>SDG-01</th>\n", + " <td>No poverty</td>\n", + " </tr>\n", + " <tr>\n", + " <th>SDG-02</th>\n", + " <td>Zero hunger</td>\n", + " </tr>\n", + " <tr>\n", + " <th>SDG-03</th>\n", + " <td>Good health and well-being</td>\n", + " </tr>\n", + " <tr>\n", + " <th>SDG-04</th>\n", + " <td>Quality education</td>\n", + " </tr>\n", + " <tr>\n", + " <th>SDG-05</th>\n", + " <td>Gender equality</td>\n", + " </tr>\n", + " <tr>\n", + " <th>SDG-06</th>\n", + " <td>Clean water and sanitation</td>\n", + " </tr>\n", + " <tr>\n", + " <th>SDG-07</th>\n", + " <td>Affordable and clean energy</td>\n", + " </tr>\n", + " <tr>\n", + " <th>SDG-08</th>\n", + " <td>Decent work and economic growth</td>\n", + " </tr>\n", + " <tr>\n", + " <th>SDG-09</th>\n", + " <td>Industry, innovation and infrastructure</td>\n", + " </tr>\n", + " <tr>\n", + " <th>SDG-10</th>\n", + " <td>Reduced inequalities</td>\n", + " </tr>\n", + " <tr>\n", + " <th>SDG-11</th>\n", + " <td>Sustainable cities and communities</td>\n", + " </tr>\n", + " <tr>\n", + " <th>SDG-12</th>\n", + " <td>Responsible consumption and production</td>\n", + " </tr>\n", + " <tr>\n", + " <th>SDG-13</th>\n", + " <td>Climate action</td>\n", + " </tr>\n", + " <tr>\n", + " <th>SDG-14</th>\n", + " <td>Life below water</td>\n", + " </tr>\n", + " <tr>\n", + " <th>SDG-15</th>\n", + " <td>Life on land</td>\n", + " </tr>\n", + " <tr>\n", + " <th>SDG-16</th>\n", + " <td>Peace, justice and strong institutions</td>\n", + " </tr>\n", + " <tr>\n", + " <th>SDG-17</th>\n", + " <td>Partnerships for the goals</td>\n", + " </tr>\n", + " </tbody>\n", + "</table>\n", + "</div>" + ], + "text/plain": [ + " icon-text\n", + "code \n", + "SDG-01 No poverty\n", + "SDG-02 Zero hunger\n", + "SDG-03 Good health and well-being\n", + "SDG-04 Quality education\n", + "SDG-05 Gender equality\n", + "SDG-06 Clean water and sanitation\n", + "SDG-07 Affordable and clean energy\n", + "SDG-08 Decent work and economic growth\n", + "SDG-09 Industry, innovation and infrastructure\n", + "SDG-10 Reduced inequalities\n", + "SDG-11 Sustainable cities and communities\n", + "SDG-12 Responsible consumption and production\n", + "SDG-13 Climate action\n", + "SDG-14 Life below water\n", + "SDG-15 Life on land\n", + "SDG-16 Peace, justice and strong institutions\n", + "SDG-17 Partnerships for the goals" + ] + }, + "execution_count": 49, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "sdgicons.head(20)" ] }, { diff --git a/local-workshop-sources/sdg-icon-translator.xlsx b/local-workshop-sources/sdg-icon-translator.xlsx index 6f807e745107e9e6cc616ea90e03c54e8efe6b0b..a49fb1332776b41fc405e45c625e84a4d38425ee 100644 Binary files a/local-workshop-sources/sdg-icon-translator.xlsx and b/local-workshop-sources/sdg-icon-translator.xlsx differ