@@ -231,8 +231,7 @@ def process_df(df):
231
231
"Clean and reorganize the entire dataframe."
232
232
233
233
# remove HTML markers from column names
234
- for item in ['<s>a</s>', '<s>c</s>',
235
- '<s>d</s>', '<s>e</s>']:
234
+ for item in ['<s>a</s>', '<s>c</s>', '<s>d</s>', '<s>e</s>']:
236
235
df.columns = df.columns.str.replace(item, '')
237
236
238
237
# convert years to int
@@ -266,18 +265,12 @@ def pe_plot(p_seq, e_seq, index, labs, ax):
266
265
p_lab, e_lab = labs
267
266
268
267
# plot price and exchange rates
269
- ax.plot(index, p_seq,
270
- label=p_lab,
271
- color='tab:blue')
268
+ ax.plot(index, p_seq, label=p_lab, color='tab:blue')
272
269
273
270
# add a new axis
274
271
ax1 = ax.twinx()
275
- ax1.plot([None], [None],
276
- label=p_lab,
277
- color='tab:blue')
278
- ax1.plot(index, e_seq,
279
- label=e_lab,
280
- color='tab:orange')
272
+ ax1.plot([None], [None], label=p_lab, color='tab:blue')
273
+ ax1.plot(index, e_seq, label=e_lab, color='tab:orange')
281
274
282
275
# set log axes
283
276
ax.set_yscale('log')
@@ -292,20 +285,16 @@ def pe_plot(p_seq, e_seq, index, labs, ax):
292
285
label.set_rotation(45)
293
286
294
287
# set labels
295
- ax.text(-0.08, 1.03,
296
- 'Price Level',
297
- transform=ax.transAxes)
298
- ax.text(0.92, 1.03,
299
- 'Exchange Rate',
300
- transform=ax.transAxes)
288
+ ax.text(-0.08, 1.03, 'Price Level', transform=ax.transAxes)
289
+ ax.text(0.92, 1.03, 'Exchange Rate', transform=ax.transAxes)
301
290
302
291
ax1.legend(loc='upper left')
303
292
304
293
return ax1
305
294
306
295
def pr_plot(p_seq, index, ax):
307
296
"Generate plots for inflation rates."
308
-
297
+
309
298
# alculate the difference of log p_seq
310
299
log_diff_p = np.diff(np.log(p_seq))
311
300
@@ -315,11 +304,8 @@ def pr_plot(p_seq, index, ax):
315
304
color='tab:grey')
316
305
317
306
# calculate and plot moving average
318
- diff_smooth = pd.DataFrame(
319
- log_diff_p).rolling(3).mean()
320
- ax.plot(index[1:], diff_smooth,
321
- alpha=0.5,
322
- color='tab:grey')
307
+ diff_smooth = pd.DataFrame(log_diff_p).rolling(3).mean()
308
+ ax.plot(index[1:], diff_smooth, alpha=0.5, color='tab:grey')
323
309
ax.text(-0.08, 1.03,
324
310
'Monthly Inflation Rate',
325
311
transform=ax.transAxes)
@@ -363,10 +349,8 @@ for i in range(4):
363
349
364
350
# apply process_entry on the selected sheet
365
351
sheet_list = [
366
- pd.read_excel(
367
- xls,
368
- 'Table3.' + str(ind),
369
- header=1).iloc[:row].applymap(process_entry)
352
+ pd.read_excel(xls, 'Table3.' + str(ind),
353
+ header=1).iloc[:row].applymap(process_entry)
370
354
for ind, row in zip(indices, rows)]
371
355
372
356
sheet_list = [process_df(df) for df in sheet_list]
@@ -398,18 +382,14 @@ The sources of our data are:
398
382
* Table 3.4, exchange rate with US
399
383
400
384
``` {code-cell} ipython3
401
- p_seq = df_Aus['Retail price index,'
402
- ' 52 commodities']
385
+ p_seq = df_Aus['Retail price index, 52 commodities']
403
386
e_seq = df_Aus['Exchange Rate']
404
387
405
- lab = ['Retail Price Index',
406
- 'Exchange Rate']
388
+ lab = ['Retail Price Index', 'Exchange Rate']
407
389
408
390
# create plot
409
391
fig, ax = plt.subplots(figsize=[10,7], dpi=200)
410
- _ = pe_plot(p_seq, e_seq,
411
- df_Aus.index,
412
- lab, ax)
392
+ _ = pe_plot(p_seq, e_seq, df_Aus.index, lab, ax)
413
393
414
394
# connect disjunct parts
415
395
plt.figtext(0.5, -0.02, 'Austria',
@@ -453,9 +433,7 @@ lab = ['Hungarian Index of Prices',
453
433
454
434
# create plot
455
435
fig, ax = plt.subplots(figsize=[10,7], dpi=200)
456
- _ = pe_plot(p_seq, e_seq,
457
- df_Hung.index,
458
- lab, ax)
436
+ _ = pe_plot(p_seq, e_seq, df_Hung.index, lab, ax)
459
437
460
438
plt.figtext(0.5, -0.02, 'Hungary',
461
439
horizontalalignment='center',
@@ -499,10 +477,8 @@ p_seq3 = df_Pol['Wholesale Price Index: '
499
477
mask_1 = p_seq1[~p_seq1.isna()].index[-1]
500
478
mask_2 = p_seq2[~p_seq2.isna()].index[-2]
501
479
502
- adj_ratio12 = (p_seq1[mask_1]
503
- / p_seq2[mask_1])
504
- adj_ratio23 = (p_seq2[mask_2]
505
- / p_seq3[mask_2])
480
+ adj_ratio12 = (p_seq1[mask_1] / p_seq2[mask_1])
481
+ adj_ratio23 = (p_seq2[mask_2] / p_seq3[mask_2])
506
482
507
483
# glue three series
508
484
p_seq = pd.concat([p_seq1[:mask_1],
@@ -511,8 +487,7 @@ p_seq = pd.concat([p_seq1[:mask_1],
511
487
p_seq = p_seq[~p_seq.index.duplicated(keep='first')]
512
488
513
489
# exchange rate
514
- e_seq = 1/df_Pol['Cents per Polish mark '
515
- '(zloty after May 1924)']
490
+ e_seq = 1/df_Pol['Cents per Polish mark (zloty after May 1924)']
516
491
e_seq[e_seq.index > '05-01-1924'] = np.nan
517
492
```
518
493
@@ -522,9 +497,7 @@ lab = ['Wholesale Price Index',
522
497
523
498
# create plot
524
499
fig, ax = plt.subplots(figsize=[10,7], dpi=200)
525
- ax1 = pe_plot(p_seq, e_seq,
526
- df_Pol.index,
527
- lab, ax)
500
+ ax1 = pe_plot(p_seq, e_seq, df_Pol.index, lab, ax)
528
501
529
502
plt.figtext(0.5, -0.02, 'Poland',
530
503
horizontalalignment='center',
@@ -560,9 +533,7 @@ lab = ['Price Index',
560
533
561
534
# create plot
562
535
fig, ax = plt.subplots(figsize=[9,5], dpi=200)
563
- ax1 = pe_plot(p_seq, e_seq,
564
- df_Germ.index,
565
- lab, ax)
536
+ ax1 = pe_plot(p_seq, e_seq, df_Germ.index, lab, ax)
566
537
567
538
plt.figtext(0.5, -0.06, 'Germany',
568
539
horizontalalignment='center',
@@ -586,9 +557,7 @@ lab = ['Price Index (Marks or converted to Marks)',
586
557
587
558
# create plot
588
559
fig, ax = plt.subplots(figsize=[10,7], dpi=200)
589
- ax1 = pe_plot(p_seq, e_seq,
590
- df_Germ.index,
591
- lab, ax)
560
+ ax1 = pe_plot(p_seq, e_seq, df_Germ.index, lab, ax)
592
561
593
562
plt.figtext(0.5, -0.02, 'Germany',
594
563
horizontalalignment='center',
0 commit comments