@@ -4,7 +4,7 @@ jupytext:
44 extension : .md
55 format_name : myst
66 format_version : 0.13
7- jupytext_version : 1.14.5
7+ jupytext_version : 1.16.1
88kernelspec :
99 display_name : Python 3 (ipykernel)
1010 language : python
@@ -53,7 +53,6 @@ cycler = plt.cycler(linestyle=['-', '-.', '--', ':'],
5353plt.rc('axes', prop_cycle=cycler)
5454```
5555
56-
5756## Data acquisition
5857
5958We 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.
6766wb.series.info(q='GDP growth')
6867```
6968
70-
7169Now we use this series ID to obtain the data.
7270
7371``` {code-cell} ipython3
@@ -77,7 +75,6 @@ gdp_growth = wb.data.DataFrame('NY.GDP.MKTP.KD.ZG',
7775gdp_growth
7876```
7977
80-
8178We can look at the series' metadata to learn more about the series (click to expand).
8279
8380``` {code-cell} ipython3
@@ -86,8 +83,6 @@ We can look at the series' metadata to learn more about the series (click to exp
8683wb.series.metadata.get('NY.GDP.MKTP.KD.ZG')
8784```
8885
89-
90-
9186(gdp_growth)=
9287## GDP growth rate
9388
@@ -186,17 +181,15 @@ t_params = {'color':'grey', 'fontsize': 9,
186181 'va':'center', 'ha':'center'}
187182```
188183
189-
190184Let's start with the United States.
191185
192186``` {code-cell} ipython3
193187---
194188mystnb:
195189 figure:
196- caption: " United States (GDP growth rate %)"
190+ caption: United States (GDP growth rate %)
197191 name: us_gdp
198192---
199-
200193fig, ax = plt.subplots()
201194
202195country = 'United States'
@@ -226,10 +219,9 @@ Notice the very large dip during the Covid-19 pandemic.
226219---
227220mystnb:
228221 figure:
229- caption: " United Kingdom (GDP growth rate %)"
222+ caption: United Kingdom (GDP growth rate %)
230223 name: uk_gdp
231224---
232-
233225fig, ax = plt.subplots()
234226
235227country = 'United Kingdom'
@@ -251,10 +243,9 @@ Global Financial Crisis (GFC) and the Covid-19 pandemic.
251243---
252244mystnb:
253245 figure:
254- caption: " Japan (GDP growth rate %)"
246+ caption: Japan (GDP growth rate %)
255247 name: jp_gdp
256248---
257-
258249fig, ax = plt.subplots()
259250
260251country = 'Japan'
@@ -270,10 +261,9 @@ Now let's study Greece.
270261---
271262mystnb:
272263 figure:
273- caption: " Greece (GDP growth rate %)"
264+ caption: Greece (GDP growth rate %)
274265 name: gc_gdp
275266---
276-
277267fig, ax = plt.subplots()
278268
279269country = 'Greece'
@@ -292,10 +282,9 @@ Next let's consider Argentina.
292282---
293283mystnb:
294284 figure:
295- caption: " Argentina (GDP growth rate %)"
285+ caption: Argentina (GDP growth rate %)
296286 name: arg_gdp
297287---
298-
299288fig, ax = plt.subplots()
300289
301290country = 'Argentina'
@@ -343,11 +332,10 @@ defined by the NBER.
343332---
344333mystnb:
345334 figure:
346- caption: " Long-run unemployment rate, US (%)"
335+ caption: Long-run unemployment rate, US (%)
347336 name: lrunrate
348337tags: [hide-input]
349338---
350-
351339# We use the census bureau's estimate for the unemployment rate
352340# between 1942 and 1948
353341years = [datetime.datetime(year, 6, 1) for year in range(1942, 1948)]
@@ -390,7 +378,6 @@ ax.set_ylabel('unemployment rate (%)')
390378plt.show()
391379```
392380
393-
394381The plot shows that
395382
396383* 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
418405that includes multiple countries.
419406
420407``` {code-cell} ipython3
421- ---
422- tags: [hide-input]
423- ---
408+ :tags: [hide-input]
424409
425410
426411def plot_comparison(data, countries,
@@ -497,17 +482,14 @@ t_params = {'color':'grey', 'fontsize': 9,
497482Here we compare the GDP growth rate of developed economies and developing economies.
498483
499484``` {code-cell} ipython3
500- ---
501- tags: [hide-input]
502- ---
485+ :tags: [hide-input]
503486
504487# Obtain GDP growth rate for a list of countries
505488gdp_growth = wb.data.DataFrame('NY.GDP.MKTP.KD.ZG',
506489 ['CHN', 'USA', 'DEU', 'BRA', 'ARG', 'GBR', 'JPN', 'MEX'],
507490 labels=True)
508491gdp_growth = gdp_growth.set_index('Country')
509492gdp_growth.columns = gdp_growth.columns.str.replace('YR', '').astype(int)
510-
511493```
512494
513495We 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
516498---
517499mystnb:
518500 figure:
519- caption: " Developed economies (GDP growth rate %)"
501+ caption: Developed economies (GDP growth rate %)
520502 name: adv_gdp
521503tags: [hide-input]
522504---
523-
524505fig, ax = plt.subplots()
525506countries = ['United Kingdom', 'United States', 'Germany', 'Japan']
526507ylabel = 'GDP growth rate (%)'
@@ -537,11 +518,10 @@ We choose Brazil, China, Argentina, and Mexico as representative developing econ
537518---
538519mystnb:
539520 figure:
540- caption: " Developing economies (GDP growth rate %)"
521+ caption: Developing economies (GDP growth rate %)
541522 name: deve_gdp
542523tags: [hide-input]
543524---
544-
545525fig, ax = plt.subplots()
546526countries = ['Brazil', 'China', 'Argentina', 'Mexico']
547527plot_comparison(gdp_growth.loc[countries, 1962:],
@@ -551,7 +531,6 @@ plot_comparison(gdp_growth.loc[countries, 1962:],
551531plt.show()
552532```
553533
554-
555534The comparison of GDP growth rates above suggests that
556535business cycles are becoming more synchronized in 21st-century recessions.
557536
@@ -571,11 +550,10 @@ the United Kingdom, Japan, and France.
571550---
572551mystnb:
573552 figure:
574- caption: " Developed economies (unemployment rate %)"
553+ caption: Developed economies (unemployment rate %)
575554 name: adv_unemp
576555tags: [hide-input]
577556---
578-
579557unempl_rate = wb.data.DataFrame('SL.UEM.TOTL.NE.ZS',
580558 ['USA', 'FRA', 'GBR', 'JPN'], labels=True)
581559unempl_rate = unempl_rate.set_index('Country')
@@ -623,11 +601,10 @@ year-on-year
623601---
624602mystnb:
625603 figure:
626- caption: " Consumer sentiment index and YoY CPI change, US"
604+ caption: Consumer sentiment index and YoY CPI change, US
627605 name: csicpi
628606tags: [hide-input]
629607---
630-
631608start_date = datetime.datetime(1978, 1, 1)
632609end_date = datetime.datetime(2022, 12, 31)
633610
@@ -705,11 +682,10 @@ from 1919 to 2022 in the US to show this trend.
705682---
706683mystnb:
707684 figure:
708- caption: " YoY real output change, US (%)"
685+ caption: YoY real output change, US (%)
709686 name: roc
710687tags: [hide-input]
711688---
712-
713689start_date = datetime.datetime(1919, 1, 1)
714690end_date = datetime.datetime(2022, 12, 31)
715691
@@ -753,11 +729,10 @@ percentage of GDP by banks from 1970 to 2022 in the UK.
753729---
754730mystnb:
755731 figure:
756- caption: " Domestic credit to private sector by banks (% of GDP)"
732+ caption: Domestic credit to private sector by banks (% of GDP)
757733 name: dcpc
758734tags: [hide-input]
759735---
760-
761736private_credit = wb.data.DataFrame('FS.AST.PRVT.GD.ZS',
762737 ['GBR'], labels=True)
763738private_credit = private_credit.set_index('Country')
0 commit comments