Skip to content

Commit 0216cc1

Browse files
mmckylongye-tian
andauthored
[inflation_history] ENH: Implement review suggestions and comments (#494)
* [inflation_history] ENH: Implement review suggestions and comments * remove dots and show only moving average line * update 1/cents per polish mark --------- Co-authored-by: Longye Tian <[email protected]>
1 parent d6194b1 commit 0216cc1

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

Diff for: lectures/inflation_history.md

+12-16
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,15 @@ The `xlrd` package is used by `pandas` to perform operations on Excel files.
2121

2222
```{code-cell} ipython3
2323
:tags: [hide-output]
24+
2425
!pip install xlrd
2526
```
2627

2728
<!-- Check for pandas>=2.1.4 for Google Collab Compat -->
2829

2930
```{code-cell} ipython3
3031
:tags: [hide-cell]
32+
3133
from importlib.metadata import version
3234
from packaging.version import Version
3335
@@ -100,16 +102,16 @@ mystnb:
100102
caption: Long run time series of the price level
101103
name: lrpl
102104
---
103-
df_fig5_bef1914 = df_fig5[df_fig5.index <= 1915]
105+
df_fig5_befe1914 = df_fig5[df_fig5.index <= 1914]
104106
105107
# Create plot
106108
cols = ['UK', 'US', 'France', 'Castile']
107109
108-
fig, ax = plt.subplots(dpi=200)
110+
fig, ax = plt.subplots(figsize=(10,6))
109111
110112
for col in cols:
111-
ax.plot(df_fig5_bef1914.index,
112-
df_fig5_bef1914[col], label=col, lw=2)
113+
ax.plot(df_fig5_befe1914.index,
114+
df_fig5_befe1914[col], label=col, lw=2)
113115
114116
ax.legend()
115117
ax.set_ylabel('Index 1913 = 100')
@@ -327,11 +329,6 @@ def pr_plot(p_seq, index, ax):
327329
# Calculate the difference of log p_seq
328330
log_diff_p = np.diff(np.log(p_seq))
329331
330-
# Graph for the difference of log p_seq
331-
ax.scatter(index[1:], log_diff_p,
332-
label='Monthly inflation rate',
333-
color='tab:grey')
334-
335332
# Calculate and plot moving average
336333
diff_smooth = pd.DataFrame(log_diff_p).rolling(3, center=True).mean()
337334
ax.plot(index[1:], diff_smooth, label='Moving average (3 period)', alpha=0.5, lw=2)
@@ -345,7 +342,7 @@ def pr_plot(p_seq, index, ax):
345342
for label in ax.get_xticklabels():
346343
label.set_rotation(45)
347344
348-
ax.legend(loc='upper left')
345+
ax.legend()
349346
350347
return ax
351348
```
@@ -419,7 +416,7 @@ p_seq = df_aus['Retail price index, 52 commodities']
419416
e_seq = df_aus['Exchange Rate']
420417
421418
lab = ['Retail price index',
422-
'1/cents per Austrian Krone (Crown)']
419+
'Austrian Krones (Crowns) per US cent']
423420
424421
# Create plot
425422
fig, ax = plt.subplots(dpi=200)
@@ -463,12 +460,11 @@ mystnb:
463460
caption: Price index and exchange rate (Hungary)
464461
name: pi_xrate_hungary
465462
---
466-
m_seq = df_hun['Notes in circulation']
467463
p_seq = df_hun['Hungarian index of prices']
468464
e_seq = 1 / df_hun['Cents per crown in New York']
469465
470466
lab = ['Hungarian index of prices',
471-
'1/cents per Hungarian Korona (Crown)']
467+
'Hungarian Koronas (Crowns) per US cent']
472468
473469
# Create plot
474470
fig, ax = plt.subplots(dpi=200)
@@ -537,7 +533,7 @@ e_seq[e_seq.index > '05-01-1924'] = np.nan
537533

538534
```{code-cell} ipython3
539535
lab = ['Wholesale price index',
540-
'1/cents per polish mark']
536+
'Polish marks per US cent']
541537
542538
# Create plot
543539
fig, ax = plt.subplots(dpi=200)
@@ -579,7 +575,7 @@ p_seq = df_deu['Price index (on basis of marks before July 1924,'
579575
e_seq = 1/df_deu['Cents per mark']
580576
581577
lab = ['Price index',
582-
'1/cents per mark']
578+
'Marks per US cent']
583579
584580
# Create plot
585581
fig, ax = plt.subplots(dpi=200)
@@ -606,7 +602,7 @@ e_seq[e_seq.index > '12-01-1923'] = e_seq[e_seq.index
606602
> '12-01-1923'] * 1e12
607603
608604
lab = ['Price index (marks or converted to marks)',
609-
'1/cents per mark (or reichsmark converted to mark)']
605+
'Marks per US cent(or reichsmark converted to mark)']
610606
611607
# Create plot
612608
fig, ax = plt.subplots(dpi=200)

0 commit comments

Comments
 (0)