@@ -4,7 +4,7 @@ jupytext:
4
4
extension : .md
5
5
format_name : myst
6
6
format_version : 0.13
7
- jupytext_version : 1.14.5
7
+ jupytext_version : 1.16.1
8
8
kernelspec :
9
9
display_name : Python 3 (ipykernel)
10
10
language : python
@@ -53,7 +53,6 @@ cycler = plt.cycler(linestyle=['-', '-.', '--', ':'],
53
53
plt.rc('axes', prop_cycle=cycler)
54
54
```
55
55
56
-
57
56
## Data acquisition
58
57
59
58
We will use the World Bank's data API ` wbgapi ` and ` pandas_datareader ` to retrieve data.
@@ -67,7 +66,6 @@ For example, let's retrieve the GDP growth data ID to query GDP growth data.
67
66
wb.series.info(q='GDP growth')
68
67
```
69
68
70
-
71
69
Now we use this series ID to obtain the data.
72
70
73
71
``` {code-cell} ipython3
@@ -77,7 +75,6 @@ gdp_growth = wb.data.DataFrame('NY.GDP.MKTP.KD.ZG',
77
75
gdp_growth
78
76
```
79
77
80
-
81
78
We can look at the series' metadata to learn more about the series (click to expand).
82
79
83
80
``` {code-cell} ipython3
@@ -86,8 +83,6 @@ We can look at the series' metadata to learn more about the series (click to exp
86
83
wb.series.metadata.get('NY.GDP.MKTP.KD.ZG')
87
84
```
88
85
89
-
90
-
91
86
(gdp_growth)=
92
87
## GDP growth rate
93
88
@@ -186,17 +181,15 @@ t_params = {'color':'grey', 'fontsize': 9,
186
181
'va':'center', 'ha':'center'}
187
182
```
188
183
189
-
190
184
Let's start with the United States.
191
185
192
186
``` {code-cell} ipython3
193
187
---
194
188
mystnb:
195
189
figure:
196
- caption: " United States (GDP growth rate %)"
190
+ caption: United States (GDP growth rate %)
197
191
name: us_gdp
198
192
---
199
-
200
193
fig, ax = plt.subplots()
201
194
202
195
country = 'United States'
@@ -226,10 +219,9 @@ Notice the very large dip during the Covid-19 pandemic.
226
219
---
227
220
mystnb:
228
221
figure:
229
- caption: " United Kingdom (GDP growth rate %)"
222
+ caption: United Kingdom (GDP growth rate %)
230
223
name: uk_gdp
231
224
---
232
-
233
225
fig, ax = plt.subplots()
234
226
235
227
country = 'United Kingdom'
@@ -251,10 +243,9 @@ Global Financial Crisis (GFC) and the Covid-19 pandemic.
251
243
---
252
244
mystnb:
253
245
figure:
254
- caption: " Japan (GDP growth rate %)"
246
+ caption: Japan (GDP growth rate %)
255
247
name: jp_gdp
256
248
---
257
-
258
249
fig, ax = plt.subplots()
259
250
260
251
country = 'Japan'
@@ -270,10 +261,9 @@ Now let's study Greece.
270
261
---
271
262
mystnb:
272
263
figure:
273
- caption: " Greece (GDP growth rate %)"
264
+ caption: Greece (GDP growth rate %)
274
265
name: gc_gdp
275
266
---
276
-
277
267
fig, ax = plt.subplots()
278
268
279
269
country = 'Greece'
@@ -292,10 +282,9 @@ Next let's consider Argentina.
292
282
---
293
283
mystnb:
294
284
figure:
295
- caption: " Argentina (GDP growth rate %)"
285
+ caption: Argentina (GDP growth rate %)
296
286
name: arg_gdp
297
287
---
298
-
299
288
fig, ax = plt.subplots()
300
289
301
290
country = 'Argentina'
@@ -343,11 +332,10 @@ defined by the NBER.
343
332
---
344
333
mystnb:
345
334
figure:
346
- caption: " Long-run unemployment rate, US (%)"
335
+ caption: Long-run unemployment rate, US (%)
347
336
name: lrunrate
348
337
tags: [hide-input]
349
338
---
350
-
351
339
# We use the census bureau's estimate for the unemployment rate
352
340
# between 1942 and 1948
353
341
years = [datetime.datetime(year, 6, 1) for year in range(1942, 1948)]
@@ -390,7 +378,6 @@ ax.set_ylabel('unemployment rate (%)')
390
378
plt.show()
391
379
```
392
380
393
-
394
381
The plot shows that
395
382
396
383
* expansions and contractions of the labor market have been highly correlated
@@ -418,9 +405,7 @@ With slight modifications, we can use our previous function to draw a plot
418
405
that includes multiple countries.
419
406
420
407
``` {code-cell} ipython3
421
- ---
422
- tags: [hide-input]
423
- ---
408
+ :tags: [hide-input]
424
409
425
410
426
411
def plot_comparison(data, countries,
@@ -497,17 +482,14 @@ t_params = {'color':'grey', 'fontsize': 9,
497
482
Here we compare the GDP growth rate of developed economies and developing economies.
498
483
499
484
``` {code-cell} ipython3
500
- ---
501
- tags: [hide-input]
502
- ---
485
+ :tags: [hide-input]
503
486
504
487
# Obtain GDP growth rate for a list of countries
505
488
gdp_growth = wb.data.DataFrame('NY.GDP.MKTP.KD.ZG',
506
489
['CHN', 'USA', 'DEU', 'BRA', 'ARG', 'GBR', 'JPN', 'MEX'],
507
490
labels=True)
508
491
gdp_growth = gdp_growth.set_index('Country')
509
492
gdp_growth.columns = gdp_growth.columns.str.replace('YR', '').astype(int)
510
-
511
493
```
512
494
513
495
We use the United Kingdom, United States, Germany, and Japan as examples of developed economies.
@@ -516,11 +498,10 @@ We use the United Kingdom, United States, Germany, and Japan as examples of deve
516
498
---
517
499
mystnb:
518
500
figure:
519
- caption: " Developed economies (GDP growth rate %)"
501
+ caption: Developed economies (GDP growth rate %)
520
502
name: adv_gdp
521
503
tags: [hide-input]
522
504
---
523
-
524
505
fig, ax = plt.subplots()
525
506
countries = ['United Kingdom', 'United States', 'Germany', 'Japan']
526
507
ylabel = 'GDP growth rate (%)'
@@ -537,11 +518,10 @@ We choose Brazil, China, Argentina, and Mexico as representative developing econ
537
518
---
538
519
mystnb:
539
520
figure:
540
- caption: " Developing economies (GDP growth rate %)"
521
+ caption: Developing economies (GDP growth rate %)
541
522
name: deve_gdp
542
523
tags: [hide-input]
543
524
---
544
-
545
525
fig, ax = plt.subplots()
546
526
countries = ['Brazil', 'China', 'Argentina', 'Mexico']
547
527
plot_comparison(gdp_growth.loc[countries, 1962:],
@@ -551,7 +531,6 @@ plot_comparison(gdp_growth.loc[countries, 1962:],
551
531
plt.show()
552
532
```
553
533
554
-
555
534
The comparison of GDP growth rates above suggests that
556
535
business cycles are becoming more synchronized in 21st-century recessions.
557
536
@@ -571,11 +550,10 @@ the United Kingdom, Japan, and France.
571
550
---
572
551
mystnb:
573
552
figure:
574
- caption: " Developed economies (unemployment rate %)"
553
+ caption: Developed economies (unemployment rate %)
575
554
name: adv_unemp
576
555
tags: [hide-input]
577
556
---
578
-
579
557
unempl_rate = wb.data.DataFrame('SL.UEM.TOTL.NE.ZS',
580
558
['USA', 'FRA', 'GBR', 'JPN'], labels=True)
581
559
unempl_rate = unempl_rate.set_index('Country')
@@ -623,11 +601,10 @@ year-on-year
623
601
---
624
602
mystnb:
625
603
figure:
626
- caption: " Consumer sentiment index and YoY CPI change, US"
604
+ caption: Consumer sentiment index and YoY CPI change, US
627
605
name: csicpi
628
606
tags: [hide-input]
629
607
---
630
-
631
608
start_date = datetime.datetime(1978, 1, 1)
632
609
end_date = datetime.datetime(2022, 12, 31)
633
610
@@ -705,11 +682,10 @@ from 1919 to 2022 in the US to show this trend.
705
682
---
706
683
mystnb:
707
684
figure:
708
- caption: " YoY real output change, US (%)"
685
+ caption: YoY real output change, US (%)
709
686
name: roc
710
687
tags: [hide-input]
711
688
---
712
-
713
689
start_date = datetime.datetime(1919, 1, 1)
714
690
end_date = datetime.datetime(2022, 12, 31)
715
691
@@ -753,11 +729,10 @@ percentage of GDP by banks from 1970 to 2022 in the UK.
753
729
---
754
730
mystnb:
755
731
figure:
756
- caption: " Domestic credit to private sector by banks (% of GDP)"
732
+ caption: Domestic credit to private sector by banks (% of GDP)
757
733
name: dcpc
758
734
tags: [hide-input]
759
735
---
760
-
761
736
private_credit = wb.data.DataFrame('FS.AST.PRVT.GD.ZS',
762
737
['GBR'], labels=True)
763
738
private_credit = private_credit.set_index('Country')
0 commit comments