forked from open-numbers/ddf--gapminder--systema_globalis
-
Notifications
You must be signed in to change notification settings - Fork 2
/
recipe_unpop.yaml
384 lines (376 loc) · 18.7 KB
/
recipe_unpop.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
# basic info
# TODO: sex_ratio should *100, percentage need to double check. big diff to candidate
info:
id: unpop_sg_dataset
base:
- &d1 ddf--unpop--wpp_pop
- &d2 ddf--gapminder--gapminder_world
- &d3 ddf--unpop--wpp_demog
config:
# the path to search recipe files to include
recipes_dir: ./
# the path to search dictionary files
dictionary_dir: ../translation_dictionaries
# the path to search ddf datasets
ddf_dir: /Users/semio/src/work/Gapminder
include:
- recipe_gw_common.yaml
ingredients:
- id: unpop-datapoints-gender
dataset: *d1
key: "country_code,year,gender,age"
value: "*"
# total population can be calculated from male + female, so
# we skip this one here.
# - id: unpop-datapoints-total
# dataset: *d1
# key: "country_code,year,age"
value: "*"
- id: unpop-countries
dataset: *d1
key: [country_code]
value: "*"
- id: unpop-datapoints-demog
dataset: *d3
key: "country_code,year"
value:
- crude_birth_rate
- crude_death_rate
- life_expectancy_at_birth_females
- life_expectancy_at_birth_males
- population_growth_rate
- id: gw-concepts-unpop
dataset: *d2
key: concept
value: '*'
filter:
concept: &CONCEPT_FILTER
- crude_birth_rate_births_per_1000_population
- crude_death_rate_deaths_per_1000_population
- life_expectancy_female
- life_expectancy_male
- population_growth_annual_percent_with_projections
- female_population_with_projections
- male_population_with_projections
- sex_ratio_0_14_years
- sex_ratio_15_24_years
- sex_ratio_15_49_years
- sex_ratio_above_50_years
- sex_ratio_all_age_groups
- population_aged_0_4_years_both_sexes_percent
- population_aged_0_4_years_female_percent
- population_aged_0_4_years_male_percent
- population_aged_0_4_years_total_number
- population_aged_10_14_years_both_sexes_percent
- population_aged_10_14_years_female_percent
- population_aged_10_14_years_male_percent
- population_aged_10_14_years_total_number
- population_aged_15_19_years_both_sexes_percent
- population_aged_15_19_years_female_percent
- population_aged_15_19_years_male_percent
- population_aged_15_19_years_total_number
- population_aged_20_39_years_both_sexes_percent
- population_aged_20_39_years_female_percent
- population_aged_20_39_years_male_percent
- population_aged_20_39_years_total_number
- population_aged_40_59_years_both_sexes_percent
- population_aged_40_59_years_female_percent
- population_aged_40_59_years_male_percent
- population_aged_40_59_years_total_number
- population_aged_5_9_years_both_sexes_percent
- population_aged_5_9_years_female_percent
- population_aged_5_9_years_male_percent
- population_aged_5_9_years_total_number
- population_aged_60plus_years_both_sexes_percent
- population_aged_60plus_years_female_percent
- population_aged_60plus_years_male_percent
- population_aged_60plus_years_total_number
cooking:
concepts:
- procedure: merge
ingredients:
- gw-concepts-discrete
- gw-concepts-geo
- gw-concepts-unpop
options:
deep: true
entities:
- procedure: identity
ingredients:
- gw-entities-geo
datapoints:
# WPP population
- procedure: translate_header
ingredients:
- unpop-datapoints-gender
options:
dictionary:
country_code: geo
year: time
result: unpop-datapoints-gender-translated
- procedure: align
ingredients:
- unpop-countries
- gw-countries
options:
search_cols: ['gapminder_list', 'alternative_1', 'alternative_2', 'alternative_3',
'alternative_4_cdiac', 'pandg', 'god_id', 'alt_5', 'upper_case_name',
'code', 'arb1', 'arb2', 'arb3', 'arb4', 'arb5', 'arb6', 'arb7', 'arb8',
'name']
to_find: name
to_replace: geo
result: unpop-countries-aligned
- procedure: align
ingredients:
- unpop-datapoints-gender-translated
- unpop-countries-aligned
options:
search_cols:
- country_code
to_find: geo
to_replace: geo
result: unpop-datapoints-aligned
- procedure: filter_row
ingredients:
- unpop-datapoints-aligned
result: unpop-datapoints-aligned-filtered
options:
dictionary:
female_population_total:
from: population
gender: female
male_population_total:
from: population
gender: male
# {gender}_population_{age_group} are for calculating sex_ratio and percentage
male_population_0_14_years:
from: population
gender: male
age: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14']
female_population_0_14_years:
from: population
gender: female
age: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14']
male_population_15_24_years:
from: population
gender: male
age: ['15', '16', '17', '18', '19', '20', '21', '22', '23', '24']
female_population_15_24_years:
from: population
gender: female
age: ['15', '16', '17', '18', '19', '20', '21', '22', '23', '24']
male_population_15_49_years:
from: population
gender: male
age: ['15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25',
'26', '27', '28', '29', '30', '31', '32', '33', '34', '35', '36', '37',
'38', '39', '40', '41', '42', '43', '44', '45', '46', '47', '48', '49']
female_population_15_49_years:
from: population
gender: female
age: ['15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25',
'26', '27', '28', '29', '30', '31', '32', '33', '34', '35', '36', '37',
'38', '39', '40', '41', '42', '43', '44', '45', '46', '47', '48', '49']
male_population_above_50_years:
from: population
gender: male
age: ['50', '51', '52', '53', '54', '55', '56', '57', '58', '59', '60',
'61', '62', '63', '64', '65', '66', '67', '68', '69', '70', '71', '72',
'73', '74', '75', '76', '77', '78', '79', '80', '81', '82', '83', '84',
'85', '86', '87', '88', '89', '90', '91', '92', '93', '94', '95', '96',
'97', '98', '99', '80plus', '100plus']
female_population_above_50_years:
from: population
gender: female
age: ['50', '51', '52', '53', '54', '55', '56', '57', '58', '59', '60',
'61', '62', '63', '64', '65', '66', '67', '68', '69', '70', '71', '72',
'73', '74', '75', '76', '77', '78', '79', '80', '81', '82', '83', '84',
'85', '86', '87', '88', '89', '90', '91', '92', '93', '94', '95', '96',
'97', '98', '99', '80plus', '100plus']
male_population_0_4_years:
from: population
gender: male
age: ['0', '1', '2', '3', '4']
female_population_0_4_years:
from: population
gender: female
age: ['0', '1', '2', '3', '4']
male_population_10_14_years:
from: population
gender: male
age: ['10', '11', '12', '13', '14']
female_population_10_14_years:
from: population
gender: female
age: ['10', '11', '12', '13', '14']
male_population_15_19_years:
from: population
gender: male
age: ['15', '16', '17', '18', '19']
female_population_15_19_years:
from: population
gender: female
age: ['15', '16', '17', '18', '19']
male_population_20_39_years:
from: population
gender: male
age: ['20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30',
'31', '32', '33', '34', '35', '36', '37', '38', '39']
female_population_20_39_years:
from: population
gender: female
age: ['20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30',
'31', '32', '33', '34', '35', '36', '37', '38', '39']
male_population_40_59_years:
from: population
gender: male
age: ['40', '41', '42', '43', '44', '45', '46', '47', '48', '49', '50',
'51', '52', '53', '54', '55', '56', '57', '58', '59']
female_population_40_59_years:
from: population
gender: female
age: ['40', '41', '42', '43', '44', '45', '46', '47', '48', '49', '50',
'51', '52', '53', '54', '55', '56', '57', '58', '59']
male_population_5_9_years:
from: population
gender: male
age: ['5', '6', '7', '8', '9']
female_population_5_9_years:
from: population
gender: female
age: ['5', '6', '7', '8', '9']
male_population_60plus_years:
from: population
gender: male
age: ['60', '61', '62', '63', '64', '65', '66', '67', '68', '69', '70',
'71', '72', '73', '74', '75', '76', '77', '78', '79', '80', '81', '82',
'83', '84', '85', '86', '87', '88', '89', '90', '91', '92', '93', '94',
'95', '96', '97', '98', '99', '80plus', '100plus']
female_population_60plus_years:
from: population
gender: female
age: ['60', '61', '62', '63', '64', '65', '66', '67', '68', '69', '70',
'71', '72', '73', '74', '75', '76', '77', '78', '79', '80', '81', '82',
'83', '84', '85', '86', '87', '88', '89', '90', '91', '92', '93', '94',
'95', '96', '97', '98', '99', '80plus', '100plus']
- procedure: groupby
ingredients:
- unpop-datapoints-aligned-filtered
options:
by: [geo, time]
aggregate: sum
result: unpop-datapoints-filtered-aligned-grouped
- procedure: run_op
ingredients:
- unpop-datapoints-filtered-aligned-grouped
options:
op:
sex_ratio_0_14_years:
"male_population_0_14_years / female_population_0_14_years * 100"
sex_ratio_15_24_years:
"male_population_15_24_years / female_population_15_24_years * 100"
sex_ratio_15_49_years:
"male_population_15_49_years / female_population_15_49_years * 100"
sex_ratio_above_50_years:
"male_population_above_50_years / female_population_above_50_years * 100"
sex_ratio_all_age_groups:
"male_population_total / female_population_total * 100"
female_population_with_projections:
"female_population_total * 1000"
male_population_with_projections:
"male_population_total * 1000"
population_aged_0_4_years_total_number:
"(male_population_0_4_years + female_population_0_4_years) * 1000"
population_aged_5_9_years_total_number:
"(male_population_5_9_years + female_population_5_9_years) * 1000"
population_aged_10_14_years_total_number:
"(male_population_10_14_years + female_population_10_14_years) * 1000"
population_aged_15_19_years_total_number:
"(male_population_15_19_years + female_population_15_19_years) * 1000"
population_aged_20_39_years_total_number:
"(male_population_20_39_years + female_population_20_39_years) * 1000"
population_aged_40_59_years_total_number:
"(male_population_40_59_years + female_population_40_59_years) * 1000"
population_aged_60plus_years_total_number:
"(male_population_60plus_years + female_population_60plus_years) * 1000"
population_total_number:
"male_population_total + female_population_total"
population_aged_0_4_years_both_sexes_percent:
"(male_population_0_4_years + female_population_0_4_years) / population_total_number * 100"
population_aged_5_9_years_both_sexes_percent:
"(male_population_5_9_years + female_population_5_9_years) / population_total_number * 100"
population_aged_10_14_years_both_sexes_percent:
"(male_population_10_14_years + female_population_10_14_years) / population_total_number * 100"
population_aged_15_19_years_both_sexes_percent:
"(male_population_15_19_years + female_population_15_19_years) / population_total_number * 100"
population_aged_20_39_years_both_sexes_percent:
"(male_population_20_39_years + female_population_20_39_years) / population_total_number * 100"
population_aged_40_59_years_both_sexes_percent:
"(male_population_40_59_years + female_population_40_59_years) / population_total_number * 100"
population_aged_60plus_years_both_sexes_percent:
"(male_population_60plus_years + female_population_60plus_years) / population_total_number * 100"
population_aged_0_4_years_male_percent:
"male_population_0_4_years / male_population_total * 100"
population_aged_5_9_years_male_percent:
"male_population_5_9_years / male_population_total * 100"
population_aged_10_14_years_male_percent:
"male_population_10_14_years / male_population_total * 100"
population_aged_15_19_years_male_percent:
"male_population_15_19_years / male_population_total * 100"
population_aged_20_39_years_male_percent:
"male_population_20_39_years / male_population_total * 100"
population_aged_40_59_years_male_percent:
"male_population_40_59_years / male_population_total * 100"
population_aged_60plus_years_male_percent:
"male_population_60plus_years / male_population_total * 100"
population_aged_0_4_years_female_percent:
"female_population_0_4_years / female_population_total * 100"
population_aged_5_9_years_female_percent:
"female_population_5_9_years / female_population_total * 100"
population_aged_10_14_years_female_percent:
"female_population_10_14_years / female_population_total * 100"
population_aged_15_19_years_female_percent:
"female_population_15_19_years / female_population_total * 100"
population_aged_20_39_years_female_percent:
"female_population_20_39_years / female_population_total * 100"
population_aged_40_59_years_female_percent:
"female_population_40_59_years / female_population_total * 100"
population_aged_60plus_years_female_percent:
"female_population_60plus_years / female_population_total * 100"
result: unpop-datapoints-gender-final
# WPP demographics
- procedure: translate_header
ingredients:
- unpop-datapoints-demog
options:
dictionary:
country_code: geo
year: time
crude_birth_rate: crude_birth_rate_births_per_1000_population
crude_death_rate: crude_death_rate_deaths_per_1000_population
life_expectancy_at_birth_females: life_expectancy_female
life_expectancy_at_birth_males: life_expectancy_male
population_growth_rate: population_growth_annual_percent_with_projections
result: unpop-datapoints-demog-translated
- procedure: align
ingredients:
- unpop-datapoints-demog-translated
- unpop-countries-aligned
options:
search_cols:
- country_code
to_find: geo
to_replace: geo
result: unpop-datapoints-demog-final
# merging the results
- procedure: merge
ingredients:
- unpop-datapoints-demog-final
- unpop-datapoints-gender-final
result: unpop-datapoints-merged
- procedure: filter_item
ingredients:
- unpop-datapoints-merged
options:
items: *CONCEPT_FILTER
result: unpop-datapoints-final