-
Notifications
You must be signed in to change notification settings - Fork 31
Topic Assignments by Database
Tim Herzog edited this page Jan 3, 2020
·
2 revisions
Here's a Jupyter notebook run on 1/3/2020 showing the number of indicators per topic and database. 0 shows indicators that have no topic assignment.
import wbgapi as wb
import pandas as pd
import numpy as np
dummy = pd.Series()
pd.options.display.max_columns = 50
df = pd.DataFrame()
def initval(x):
return 0 if np.isnan(x) else x
for i in wb.source.list():
index = '{} ({})'.format(i['code'], i['id'])
print('Tallying {}'.format(index))
for row in wb.fetch('https://api.worldbank.org/v2/en/indicator', {'source': i['id']}):
nTopics = 0
for t in row['topics']:
tid = int(t.get('id', 0))
if tid > 0:
df.loc[index, tid] = initval(df.get(tid,dummy).get(index,0)) + 1
nTopics += 1
if nTopics == 0:
tid = 0
df.loc[index, tid] = initval(df.get(tid,dummy).get(index,0)) + 1
df.replace(np.nan, '-').sort_index(axis=1)
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 (DBS) | 201 | - | - | - | - | 1 | - | - | - | - | - | - | 4 | - | - | - | - | - | - | 1 | - | - |
2 (WDI) | 44 | 44 | 70 | 247 | 154 | 50 | 135 | 64 | 250 | 47 | 156 | 25 | 165 | 97 | 13 | 34 | 21 | 163 | 5 | 76 | 61 | 146 |
3 (WGI) | 36 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
5 (SNM) | 5 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
6 (IDS) | - | - | 2 | 14 | - | - | - | 5 | - | - | - | - | - | - | - | - | - | - | - | - | 497 | 2 |
11 (ADI) | 808 | 40 | 47 | 203 | 76 | 25 | 37 | 44 | 125 | 58 | 84 | 18 | 99 | 72 | 7 | 32 | 17 | 98 | - | 53 | 114 | 85 |
12 (EDS) | 2361 | - | 4 | 12 | 1414 | - | - | - | 16 | 2 | 17 | - | - | - | - | 7 | - | 52 | - | 5 | 1 | - |
13 (ESY) | 89 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
14 (GDS) | 225 | 2 | 4 | 8 | 78 | - | 5 | 1 | 76 | - | 68 | 3 | 8 | 9 | - | 23 | - | 220 | - | 3 | - | - |
15 (GEM) | 38 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
16 (HNP) | 107 | 4 | 8 | 1 | 31 | - | 23 | 1 | 239 | - | 6 | 3 | - | - | - | 9 | 5 | 65 | - | 9 | - | - |
18 (IDA) | 3 | - | 9 | 8 | 8 | 1 | 3 | 1 | 14 | 3 | 7 | 3 | 2 | 1 | - | 3 | 1 | 13 | - | 10 | 3 | 1 |
19 (MDG) | 12 | 4 | 15 | 10 | 14 | 2 | 10 | - | 28 | 6 | 17 | 10 | - | 1 | - | 11 | 3 | 30 | 24 | 17 | 5 | 1 |
20 (PSD) | 564 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
22 (QDS) | 1800 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
23 (QDG) | 256 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
24 (POV) | 39 | 2 | 2 | - | - | - | - | - | 1 | - | - | 24 | - | - | - | - | 2 | - | - | 2 | - | - |
25 (JOB) | 2 | 6 | 4 | 23 | 27 | 3 | 1 | 15 | 16 | 7 | 50 | 2 | 21 | 12 | 4 | 11 | 3 | 43 | - | 11 | - | 8 |
27 (GEP) | 1 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
28 (FDX) | 776 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
29 (GSP) | 864 | - | - | - | - | - | - | - | 1 | - | 1972 | - | - | - | - | - | - | - | - | 1 | - | - |
30 (ED1) | 98 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
31 (CPI) | - | - | - | - | - | - | - | - | - | - | - | - | - | 21 | - | - | - | - | - | 1 | - | - |
32 (GFD) | 7 | - | - | 5 | - | - | - | 104 | 1 | - | - | - | - | - | - | - | - | - | - | 1 | 1 | - |
33 (G2F) | 131 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
34 (GPE) | 678 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
35 (SE4) | 11 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
36 (BBS) | 25 | - | - | - | - | - | - | - | - | - | - | - | - | 4 | - | - | - | - | - | - | - | - |
37 (LEL) | - | - | - | 18 | 2 | - | - | - | - | - | 84 | 107 | - | - | - | - | - | - | - | - | - | - |
38 (SNP) | - | 1 | - | - | - | - | - | - | - | - | - | 3 | - | - | - | - | 1 | - | - | - | - | - |
39 (HNQ) | 63 | - | - | - | - | - | - | - | 355 | - | - | - | - | - | - | - | - | - | 2 | - | - | - |
40 (HPP) | 73 | 3 | 2 | - | 2 | - | - | 1 | 84 | - | - | - | - | - | - | 2 | 3 | 17 | - | 6 | - | - |
41 (CPS) | 185 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
43 (WAT) | - | - | - | 25 | - | 9 | 27 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
45 (IDD) | 214 | 1 | - | - | - | - | - | - | 5 | - | - | - | - | - | - | - | - | 1 | - | 1 | - | - |
46 (SDG) | 24 | 9 | 11 | 35 | 85 | 11 | 64 | 4 | 87 | 15 | 55 | 7 | 14 | 10 | 4 | 14 | 9 | 76 | - | 26 | 3 | 7 |
50 (SNT) | 1 | - | - | - | - | - | - | - | 1 | - | - | - | - | - | - | - | - | - | - | 1 | - | - |
54 (JED) | 28 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
57 (WDA) | 826 | 49 | 73 | 273 | 174 | 53 | 139 | 91 | 277 | 67 | 180 | 29 | 173 | 100 | 13 | 35 | 24 | 188 | 5 | 81 | 233 | 152 |
58 (UHC) | - | - | - | - | - | - | - | - | 13 | - | - | - | - | - | - | - | - | - | - | - | - | - |
59 (WAC) | 54 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
60 (EFT) | 2 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
61 (PRQ) | 4 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
62 (ICP) | 12 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
63 (HCI) | 27 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
64 (WBI) | 87 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
65 (HPI) | 315 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
66 (LPI) | 12 | - | - | - | - | - | - | - | - | - | - | - | 7 | - | - | - | - | - | - | - | - | 7 |
67 (PF1) | 107 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
69 (RFA) | 347 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
70 (EF2) | 2 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
71 (IC5) | 17 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
73 (RFI) | 19 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
75 (ESG) | 13 | 4 | 4 | 4 | 5 | 9 | 17 | 2 | 11 | 3 | 4 | 4 | 2 | 2 | 3 | 4 | 2 | 3 | - | 16 | - | 1 |
# and here's a topic legend of sorts
for row in wb.fetch('https://api.worldbank.org/v2/en/topic'):
print('{:2} {}'.format(row['id'], row['value']))
1 Agriculture & Rural Development
2 Aid Effectiveness
3 Economy & Growth
4 Education
5 Energy & Mining
6 Environment
7 Financial Sector
8 Health
9 Infrastructure
10 Social Protection & Labor
11 Poverty
12 Private Sector
13 Public Sector
14 Science & Technology
15 Social Development
16 Urban Development
17 Gender
18 Millenium development goals
19 Climate Change
20 External Debt
21 Trade