Skip to content

[inflation_history] ENH: Implement review suggestions and comments #494

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jul 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 12 additions & 16 deletions lectures/inflation_history.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ The `xlrd` package is used by `pandas` to perform operations on Excel files.

```{code-cell} ipython3
:tags: [hide-output]

!pip install xlrd
```

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

```{code-cell} ipython3
:tags: [hide-cell]

from importlib.metadata import version
from packaging.version import Version

Expand Down Expand Up @@ -100,16 +102,16 @@ mystnb:
caption: Long run time series of the price level
name: lrpl
---
df_fig5_bef1914 = df_fig5[df_fig5.index <= 1915]
df_fig5_befe1914 = df_fig5[df_fig5.index <= 1914]

# Create plot
cols = ['UK', 'US', 'France', 'Castile']

fig, ax = plt.subplots(dpi=200)
fig, ax = plt.subplots(figsize=(10,6))

for col in cols:
ax.plot(df_fig5_bef1914.index,
df_fig5_bef1914[col], label=col, lw=2)
ax.plot(df_fig5_befe1914.index,
df_fig5_befe1914[col], label=col, lw=2)

ax.legend()
ax.set_ylabel('Index 1913 = 100')
Expand Down Expand Up @@ -327,11 +329,6 @@ def pr_plot(p_seq, index, ax):
# Calculate the difference of log p_seq
log_diff_p = np.diff(np.log(p_seq))

# Graph for the difference of log p_seq
ax.scatter(index[1:], log_diff_p,
label='Monthly inflation rate',
color='tab:grey')

# Calculate and plot moving average
diff_smooth = pd.DataFrame(log_diff_p).rolling(3, center=True).mean()
ax.plot(index[1:], diff_smooth, label='Moving average (3 period)', alpha=0.5, lw=2)
Expand All @@ -345,7 +342,7 @@ def pr_plot(p_seq, index, ax):
for label in ax.get_xticklabels():
label.set_rotation(45)

ax.legend(loc='upper left')
ax.legend()

return ax
```
Expand Down Expand Up @@ -419,7 +416,7 @@ p_seq = df_aus['Retail price index, 52 commodities']
e_seq = df_aus['Exchange Rate']

lab = ['Retail price index',
'1/cents per Austrian Krone (Crown)']
'Austrian Krones (Crowns) per US cent']

# Create plot
fig, ax = plt.subplots(dpi=200)
Expand Down Expand Up @@ -463,12 +460,11 @@ mystnb:
caption: Price index and exchange rate (Hungary)
name: pi_xrate_hungary
---
m_seq = df_hun['Notes in circulation']
p_seq = df_hun['Hungarian index of prices']
e_seq = 1 / df_hun['Cents per crown in New York']

lab = ['Hungarian index of prices',
'1/cents per Hungarian Korona (Crown)']
'Hungarian Koronas (Crowns) per US cent']

# Create plot
fig, ax = plt.subplots(dpi=200)
Expand Down Expand Up @@ -537,7 +533,7 @@ e_seq[e_seq.index > '05-01-1924'] = np.nan

```{code-cell} ipython3
lab = ['Wholesale price index',
'1/cents per polish mark']
'Polish marks per US cent']

# Create plot
fig, ax = plt.subplots(dpi=200)
Expand Down Expand Up @@ -579,7 +575,7 @@ p_seq = df_deu['Price index (on basis of marks before July 1924,'
e_seq = 1/df_deu['Cents per mark']

lab = ['Price index',
'1/cents per mark']
'Marks per US cent']

# Create plot
fig, ax = plt.subplots(dpi=200)
Expand All @@ -606,7 +602,7 @@ e_seq[e_seq.index > '12-01-1923'] = e_seq[e_seq.index
> '12-01-1923'] * 1e12

lab = ['Price index (marks or converted to marks)',
'1/cents per mark (or reichsmark converted to mark)']
'Marks per US cent(or reichsmark converted to mark)']

# Create plot
fig, ax = plt.subplots(dpi=200)
Expand Down