The dataset we'll use describes Euro daily exchange rates between 1999 and 2021. The euro (symbolized with €) is the official currency in most of the countries of the European Union.
If the exchange rate of the euro to the US dollar is 1.5, you get 1.5 US dollars if you pay 1.0 euro (one euro has more value than one US dollar at this exchange rate).
Daria Chemkaeva put together the data set and made it available on Kaggle — the data source is the European Central Bank. Note that the dataset gets regular updates — we downloaded it on January 2021.
import pandas as pd
exchange_rates = pd.read_csv('euro-daily-hist_1999_2020.csv')
pd.set_option('display.max_columns', None)
print (exchange_rates.head())
exchange_rates.info()
exchange_rates.tail()
Period\Unit: [Australian dollar ] [Bulgarian lev ] [Brazilian real ] \ 0 2021-01-08 1.5758 1.9558 6.5748 1 2021-01-07 1.5836 1.9558 6.5172 2 2021-01-06 1.5824 1.9558 6.5119 3 2021-01-05 1.5927 1.9558 6.5517 4 2021-01-04 1.5928 1.9558 6.3241 [Canadian dollar ] [Swiss franc ] [Chinese yuan renminbi ] [Cypriot pound ] \ 0 1.5543 1.0827 7.9184 NaN 1 1.5601 1.0833 7.9392 NaN 2 1.5640 1.0821 7.9653 NaN 3 1.5651 1.0803 7.9315 NaN 4 1.5621 1.0811 7.9484 NaN [Czech koruna ] [Danish krone ] [Estonian kroon ] [UK pound sterling ] \ 0 26.163 7.4369 NaN 0.90128 1 26.147 7.4392 NaN 0.90190 2 26.145 7.4393 NaN 0.90635 3 26.227 7.4387 NaN 0.90333 4 26.141 7.4379 NaN 0.90160 [Greek drachma ] [Hong Kong dollar ] [Croatian kuna ] [Hungarian forint ] \ 0 NaN 9.4982 7.5690 359.62 1 NaN 9.5176 7.5660 357.79 2 NaN 9.5659 7.5595 357.86 3 NaN 9.5136 7.5588 360.27 4 NaN 9.5330 7.5565 361.32 [Indonesian rupiah ] [Israeli shekel ] [Indian rupee ] [Iceland krona ] \ 0 17247.33 3.8981 89.7975 155.5 1 17259.99 3.9027 90.0455 155.3 2 17168.20 3.9289 90.2040 156.3 3 17075.10 3.9277 89.8670 156.1 4 17062.67 3.9430 89.7890 156.1 [Japanese yen ] [Korean won ] [Lithuanian litas ] [Latvian lats ] \ 0 127.26 1337.90 NaN NaN 1 127.13 1342.29 NaN NaN 2 127.03 1339.30 NaN NaN 3 126.25 1335.85 NaN NaN 4 126.62 1332.03 NaN NaN [Maltese lira ] [Mexican peso ] [Malaysian ringgit ] [Norwegian krone ] \ 0 NaN 24.4718 4.9359 10.2863 1 NaN 24.2552 4.9570 10.3435 2 NaN 24.3543 4.9482 10.3810 3 NaN 24.5860 4.9293 10.4713 4 NaN 24.3031 4.9264 10.4440 [New Zealand dollar ] [Philippine peso ] [Polish zloty ] [Romanian leu ] \ 0 1.6883 58.947 4.5113 4.8708 1 1.6907 59.043 4.4998 4.8712 2 1.6916 59.296 4.5160 4.8720 3 1.7036 59.020 4.5473 4.8721 4 1.7065 59.058 4.5475 4.8713 [Russian rouble ] [Swedish krona ] [Singapore dollar ] [Slovenian tolar ] \ 0 90.8000 10.0510 1.6228 NaN 1 91.2000 10.0575 1.6253 NaN 2 90.8175 10.0653 1.6246 NaN 3 91.6715 10.0570 1.6180 NaN 4 90.3420 10.0895 1.6198 NaN [Slovak koruna ] [Thai baht ] [Turkish lira ] [US dollar ] \ 0 NaN 36.8480 9.0146 1.2250 1 NaN 36.8590 8.9987 1.2276 2 NaN 36.9210 9.0554 1.2338 3 NaN 36.7760 9.0694 1.2271 4 NaN 36.7280 9.0579 1.2296 [South African rand ] 0 18.7212 1 18.7919 2 18.5123 3 18.4194 4 17.9214 <class 'pandas.core.frame.DataFrame'> RangeIndex: 5699 entries, 0 to 5698 Data columns (total 41 columns): # Column Non-Null Count Dtype --- ------ -------------- ----- 0 Period\Unit: 5699 non-null object 1 [Australian dollar ] 5699 non-null object 2 [Bulgarian lev ] 5297 non-null object 3 [Brazilian real ] 5431 non-null object 4 [Canadian dollar ] 5699 non-null object 5 [Swiss franc ] 5699 non-null object 6 [Chinese yuan renminbi ] 5431 non-null object 7 [Cypriot pound ] 2346 non-null object 8 [Czech koruna ] 5699 non-null object 9 [Danish krone ] 5699 non-null object 10 [Estonian kroon ] 3130 non-null object 11 [UK pound sterling ] 5699 non-null object 12 [Greek drachma ] 520 non-null object 13 [Hong Kong dollar ] 5699 non-null object 14 [Croatian kuna ] 5431 non-null object 15 [Hungarian forint ] 5699 non-null object 16 [Indonesian rupiah ] 5699 non-null object 17 [Israeli shekel ] 5431 non-null object 18 [Indian rupee ] 5431 non-null object 19 [Iceland krona ] 3292 non-null float64 20 [Japanese yen ] 5699 non-null object 21 [Korean won ] 5699 non-null object 22 [Lithuanian litas ] 4159 non-null object 23 [Latvian lats ] 3904 non-null object 24 [Maltese lira ] 2346 non-null object 25 [Mexican peso ] 5699 non-null object 26 [Malaysian ringgit ] 5699 non-null object 27 [Norwegian krone ] 5699 non-null object 28 [New Zealand dollar ] 5699 non-null object 29 [Philippine peso ] 5699 non-null object 30 [Polish zloty ] 5699 non-null object 31 [Romanian leu ] 5637 non-null float64 32 [Russian rouble ] 5699 non-null object 33 [Swedish krona ] 5699 non-null object 34 [Singapore dollar ] 5699 non-null object 35 [Slovenian tolar ] 2085 non-null object 36 [Slovak koruna ] 2608 non-null object 37 [Thai baht ] 5699 non-null object 38 [Turkish lira ] 5637 non-null float64 39 [US dollar ] 5699 non-null object 40 [South African rand ] 5699 non-null object dtypes: float64(3), object(38) memory usage: 1.8+ MB
Period\Unit: | [Australian dollar ] | [Bulgarian lev ] | [Brazilian real ] | [Canadian dollar ] | [Swiss franc ] | [Chinese yuan renminbi ] | [Cypriot pound ] | [Czech koruna ] | [Danish krone ] | [Estonian kroon ] | [UK pound sterling ] | [Greek drachma ] | [Hong Kong dollar ] | [Croatian kuna ] | [Hungarian forint ] | [Indonesian rupiah ] | [Israeli shekel ] | [Indian rupee ] | [Iceland krona ] | [Japanese yen ] | [Korean won ] | [Lithuanian litas ] | [Latvian lats ] | [Maltese lira ] | [Mexican peso ] | [Malaysian ringgit ] | [Norwegian krone ] | [New Zealand dollar ] | [Philippine peso ] | [Polish zloty ] | [Romanian leu ] | [Russian rouble ] | [Swedish krona ] | [Singapore dollar ] | [Slovenian tolar ] | [Slovak koruna ] | [Thai baht ] | [Turkish lira ] | [US dollar ] | [South African rand ] | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
5694 | 1999-01-08 | 1.8406 | NaN | NaN | 1.7643 | 1.6138 | NaN | 0.58187 | 34.938 | 7.4433 | 15.6466 | 0.70940 | 324.00 | 9.0302 | NaN | 250.15 | 9321.63 | NaN | NaN | 80.99 | 130.09 | 1366.73 | 4.66430 | 0.6654 | 0.4419 | 11.4414 | 4.4295 | 8.5900 | 2.1557 | 44.295 | 4.0363 | 1.3143 | 27.2075 | 9.1650 | 1.9537 | 188.8400 | 42.560 | 42.5590 | 0.3718 | 1.1659 | 6.7855 |
5695 | 1999-01-07 | 1.8474 | NaN | NaN | 1.7602 | 1.6165 | NaN | 0.58187 | 34.886 | 7.4431 | 15.6466 | 0.70585 | 324.40 | 9.0131 | NaN | 250.09 | 9218.77 | NaN | NaN | 81.06 | 129.43 | 1337.16 | 4.65480 | 0.6627 | 0.4413 | 11.5511 | 4.4203 | 8.6295 | 2.1531 | 44.436 | 4.0165 | 1.3092 | 26.9876 | 9.1800 | 1.9436 | 188.8000 | 42.765 | 42.1678 | 0.3701 | 1.1632 | 6.8283 |
5696 | 1999-01-06 | 1.8820 | NaN | NaN | 1.7711 | 1.6116 | NaN | 0.58200 | 34.850 | 7.4452 | 15.6466 | 0.70760 | 324.72 | 9.1010 | NaN | 250.67 | 9337.68 | NaN | NaN | 81.54 | 131.42 | 1359.54 | 4.69940 | 0.6649 | 0.4420 | 11.4705 | 4.4637 | 8.7335 | 2.1890 | 44.872 | 4.0065 | 1.3168 | 27.4315 | 9.3050 | 1.9699 | 188.7000 | 42.778 | 42.6949 | 0.3722 | 1.1743 | 6.7307 |
5697 | 1999-01-05 | 1.8944 | NaN | NaN | 1.7965 | 1.6123 | NaN | 0.58230 | 34.917 | 7.4495 | 15.6466 | 0.71220 | 324.70 | 9.1341 | NaN | 250.80 | 9314.51 | NaN | NaN | 81.53 | 130.96 | 1373.01 | 4.71740 | 0.6657 | 0.4432 | 11.5960 | 4.4805 | 8.7745 | 2.2011 | 44.745 | 4.0245 | 1.3168 | 26.5876 | 9.4025 | 1.9655 | 188.7750 | 42.848 | 42.5048 | 0.3728 | 1.1790 | 6.7975 |
5698 | 1999-01-04 | 1.9100 | NaN | NaN | 1.8004 | 1.6168 | NaN | 0.58231 | 35.107 | 7.4501 | 15.6466 | 0.71110 | 327.15 | 9.1332 | NaN | 251.48 | 9433.61 | NaN | NaN | 81.48 | 133.73 | 1398.59 | 4.71700 | 0.6668 | 0.4432 | 11.6446 | 4.4798 | 8.8550 | 2.2229 | 45.510 | 4.0712 | 1.3111 | 25.2875 | 9.4696 | 1.9554 | 189.0450 | 42.991 | 42.6799 | 0.3723 | 1.1789 | 6.9358 |
exchange_rates.rename(columns={'[US dollar ]': 'US_dollar','[UK pound sterling ]':'GBP','[Swiss franc ]':'CHF','[Mexican peso ]':'MXN',
'Period\\Unit:': 'Time'},
inplace=True)
exchange_rates['Time'] = pd.to_datetime(exchange_rates['Time'])
exchange_rates.sort_values('Time', inplace=True)
exchange_rates.reset_index(drop=True, inplace=True)
euro_to_dollar = exchange_rates[["Time", "US_dollar"]]
euro_to_dollar.info()
<class 'pandas.core.frame.DataFrame'> RangeIndex: 5699 entries, 0 to 5698 Data columns (total 2 columns): # Column Non-Null Count Dtype --- ------ -------------- ----- 0 Time 5699 non-null datetime64[ns] 1 US_dollar 5699 non-null object dtypes: datetime64[ns](1), object(1) memory usage: 89.2+ KB
euro_to_dollar["US_dollar"].value_counts()
- 62 1.2276 9 1.1215 8 1.1305 7 1.3086 6 .. 1.2437 1 1.2688 1 0.8712 1 0.9009 1 1.2322 1 Name: US_dollar, Length: 3528, dtype: int64
euro_to_dollar = euro_to_dollar.loc[euro_to_dollar["US_dollar"] != '-']
euro_to_dollar["US_dollar"].value_counts()
1.2276 9 1.1215 8 1.1305 7 1.1218 6 1.0888 6 .. 1.0424 1 1.2437 1 1.2688 1 0.8712 1 1.3353 1 Name: US_dollar, Length: 3527, dtype: int64
euro_to_dollar["US_dollar"] = euro_to_dollar["US_dollar"].astype(float)
euro_to_dollar.info()
<class 'pandas.core.frame.DataFrame'> Int64Index: 5637 entries, 0 to 5698 Data columns (total 2 columns): # Column Non-Null Count Dtype --- ------ -------------- ----- 0 Time 5637 non-null datetime64[ns] 1 US_dollar 5637 non-null float64 dtypes: datetime64[ns](1), float64(1) memory usage: 132.1 KB
euro_to_dollar['rolling_mean'] = euro_to_dollar["US_dollar"].rolling(30).mean()
euro_to_dollar.head()
Time | US_dollar | rolling_mean | |
---|---|---|---|
0 | 1999-01-04 | 1.1789 | NaN |
1 | 1999-01-05 | 1.1790 | NaN |
2 | 1999-01-06 | 1.1743 | NaN |
3 | 1999-01-07 | 1.1632 | NaN |
4 | 1999-01-08 | 1.1659 | NaN |
import matplotlib.pyplot as plt
%matplotlib inline
#Enables Jupyter to display graphs
plt.plot(euro_to_dollar['Time'],
euro_to_dollar['rolling_mean'])
plt.show()
We show comparatively how the euro-dollar rate changed before the 2008 crisis, and then how it behaved in 2008 when the crisis became worldwide, and then in 2009 when the crisis started to solve. We can use a line plot.
### Defining time periods
toda_crisis = euro_to_dollar.copy(
)[(euro_to_dollar['Time'].dt.year >= 2006) & (euro_to_dollar['Time'].dt.year < 2010)]
pre_crisis = toda_crisis.copy(
)[toda_crisis['Time'].dt.year < 2008]
crisis = toda_crisis.copy(
)[(toda_crisis['Time'].dt.year == 2008)]
post_crisis = toda_crisis.copy(
)[(toda_crisis['Time'].dt.year > 2008)]
print(pre_crisis.describe())
print(crisis.describe())
print(post_crisis.describe())
US_dollar rolling_mean count 510.000000 510.000000 mean 1.313038 1.305298 std 0.073816 0.071267 min 1.182600 1.183087 25% 1.266825 1.265212 50% 1.302000 1.300437 75% 1.358800 1.353147 max 1.487400 1.469083 US_dollar rolling_mean count 256.000000 256.000000 mean 1.470755 1.476526 std 0.103422 0.094001 min 1.246000 1.271117 25% 1.409700 1.446533 50% 1.481200 1.487007 75% 1.558000 1.559533 max 1.599000 1.574333 US_dollar rolling_mean count 256.000000 256.000000 mean 1.394782 1.389154 std 0.073108 0.068684 min 1.255500 1.274683 25% 1.327450 1.327293 50% 1.408950 1.398968 75% 1.456025 1.450326 max 1.512000 1.492740
euro_to_pound = exchange_rates[["Time", "GBP"]]
euro_to_pound.info()
<class 'pandas.core.frame.DataFrame'> RangeIndex: 5699 entries, 0 to 5698 Data columns (total 2 columns): # Column Non-Null Count Dtype --- ------ -------------- ----- 0 Time 5699 non-null datetime64[ns] 1 GBP 5699 non-null object dtypes: datetime64[ns](1), object(1) memory usage: 89.2+ KB
euro_to_pound["GBP"].value_counts()
- 62 0.90430 7 0.87750 7 0.68880 7 0.84560 7 .. 0.63255 1 0.78490 1 0.93160 1 0.78770 1 0.83525 1 Name: GBP, Length: 3470, dtype: int64
euro_to_pound = euro_to_pound.loc[euro_to_pound["GBP"] != '-']
euro_to_pound["GBP"].value_counts()
0.90430 7 0.87750 7 0.67930 7 0.68880 7 0.84560 7 .. 0.60850 1 0.63255 1 0.78490 1 0.93160 1 0.83525 1 Name: GBP, Length: 3469, dtype: int64
euro_to_pound['rolling_mean'] = euro_to_pound["GBP"].rolling(30).mean()
euro_to_pound.head()
Time | GBP | rolling_mean | |
---|---|---|---|
0 | 1999-01-04 | 0.71110 | NaN |
1 | 1999-01-05 | 0.71220 | NaN |
2 | 1999-01-06 | 0.70760 | NaN |
3 | 1999-01-07 | 0.70585 | NaN |
4 | 1999-01-08 | 0.70940 | NaN |
plt.plot(euro_to_pound['Time'],
euro_to_pound['rolling_mean'])
plt.show()
### Defining time periods for pound vs euro
toda_crisisgbp = euro_to_pound.copy(
)[(euro_to_pound['Time'].dt.year >= 2006) & (euro_to_pound['Time'].dt.year < 2010)]
pre_crisisgbp = toda_crisisgbp.copy(
)[toda_crisisgbp['Time'].dt.year < 2008]
crisisgbp = toda_crisisgbp.copy(
)[(toda_crisisgbp['Time'].dt.year == 2008)]
post_crisisgbp = toda_crisisgbp.copy(
)[(toda_crisisgbp['Time'].dt.year > 2008)& (toda_crisisgbp['Time'].dt.year < 2010) ]
print(pre_crisisgbp.describe())
print(crisisgbp.describe())
print(post_crisisgbp.describe())
rolling_mean count 510.000000 mean 0.681875 std 0.010199 min 0.662605 25% 0.675101 50% 0.680458 75% 0.686510 max 0.719267 rolling_mean count 256.000000 mean 0.785519 std 0.029563 min 0.720102 25% 0.771026 50% 0.792152 75% 0.794386 max 0.885858 rolling_mean count 256.000000 mean 0.891640 std 0.020736 min 0.856042 25% 0.871425 50% 0.899548 75% 0.907611 max 0.927397
euro_to_chf = exchange_rates[["Time", "CHF"]]
euro_to_chf.info()
<class 'pandas.core.frame.DataFrame'> RangeIndex: 5699 entries, 0 to 5698 Data columns (total 2 columns): # Column Non-Null Count Dtype --- ------ -------------- ----- 0 Time 5699 non-null datetime64[ns] 1 CHF 5699 non-null object dtypes: datetime64[ns](1), object(1) memory usage: 89.2+ KB
euro_to_chf["CHF"].value_counts()
- 62 1.2010 45 1.2009 13 1.2011 13 1.2012 10 .. 1.1257 1 1.5921 1 1.6679 1 1.2336 1 1.0516 1 Name: CHF, Length: 2920, dtype: int64
euro_to_chf= euro_to_chf.loc[euro_to_chf["CHF"] != '-']
euro_to_chf["CHF"].value_counts()
1.2010 45 1.2009 13 1.2011 13 1.2012 10 1.2014 10 .. 1.1257 1 1.5921 1 1.6679 1 1.2336 1 1.0516 1 Name: CHF, Length: 2919, dtype: int64
euro_to_chf['rolling_mean'] = euro_to_chf["CHF"].rolling(30).mean()
euro_to_chf.head()
Time | CHF | rolling_mean | |
---|---|---|---|
0 | 1999-01-04 | 1.6168 | NaN |
1 | 1999-01-05 | 1.6123 | NaN |
2 | 1999-01-06 | 1.6116 | NaN |
3 | 1999-01-07 | 1.6165 | NaN |
4 | 1999-01-08 | 1.6138 | NaN |
plt.plot(euro_to_chf['Time'],
euro_to_chf['rolling_mean'])
plt.show()
### Defining time periods for pound vs euro
toda_crisischf = euro_to_chf.copy(
)[(euro_to_chf['Time'].dt.year >= 2006) & (euro_to_chf['Time'].dt.year < 2010)]
pre_crisischf = toda_crisischf.copy(
)[toda_crisischf['Time'].dt.year < 2008]
crisischf = toda_crisischf.copy(
)[(toda_crisischf['Time'].dt.year == 2008)]
post_crisischf = toda_crisischf.copy(
)[(toda_crisischf['Time'].dt.year > 2008)& (toda_crisischf['Time'].dt.year < 2010) ]
print(pre_crisischf.describe())
print(crisischf.describe())
print(post_crisischf.describe())
rolling_mean count 510.000000 mean 1.604720 std 0.038484 min 1.547877 25% 1.569262 50% 1.594682 75% 1.646281 max 1.669480 rolling_mean count 256.000000 mean 1.594302 std 0.039123 min 1.502743 25% 1.580157 50% 1.608528 75% 1.619573 max 1.653297 rolling_mean count 256.000000 mean 1.512066 std 0.009980 min 1.486493 25% 1.510270 50% 1.513132 75% 1.517404 max 1.537533
### Adding the FiveThirtyEight style
import matplotlib.style as style
style.use('fivethirtyeight')
### Adding the subplots
plt.figure(figsize=(12, 6))
ax1 = plt.subplot(2,3,1)
ax2 = plt.subplot(2,3,2)
ax3 = plt.subplot(2,3,3)
axes = [ax1, ax2, ax3]
### Changes to all the subplots
for ax in axes:
ax.set_ylim(1.15, 1.65)
ax.set_yticks([False])
ax.grid(False)
### Ax1: Pre-crisis
ax1.plot(pre_crisis['Time'], pre_crisis['rolling_mean'],
color='#BF5FFF')
ax1.set_xticklabels([])
#print(ax1.get_xticks())
#print(ax1.get_yticks())
ax1.text(732463, 1.72, 'PRE- CRISIS', fontsize=18, weight='bold',
color='#BF5FFF')
ax1.text(732453, 1.67, 'Mean 1.305298', weight='bold',
alpha=0.3)
ax1.axhline(y=01.48, xmin=0.82, xmax=0.95, alpha=0.5, color ='grey',linestyle='dotted')
ax1.text(732793, 1.48, '1.47', weight= 'bold',
alpha=0.8, color = '#BF5FFF')
ax1.axhline(y=01.17, xmin=0.1, xmax=0.25, alpha=0.5, color ='grey',linestyle='dotted')
ax1.text(732423, 1.17, '1.18', weight= 'bold',
alpha=0.8, color = '#BF5FFF')
ax1.text(732493, 1.1, '2006-2007', weight= 'bold',
alpha=0.8, color = 'grey')
### Ax2: Crisis
ax2.plot(crisis['Time'], crisis['rolling_mean'],
color='#ffa500')
ax2.set_xticklabels([])
#print(ax2.get_xticks())
#print(ax2.get_yticks())
ax2.text(733143, 1.72, 'CRISIS', fontsize=18, weight='bold',
color='#ffa500')
ax2.text(733103, 1.67, 'Mean 1.476526', weight='bold',
alpha=0.3)
ax2.axvspan(xmin=733153, xmax=733273, ymin=0, ymax=0.9,
alpha=0.3, color='grey')
ax2.axhline(y=1.59, xmin=0.32, xmax=0.61, alpha=0.5, color ='grey',linestyle='dotted')
ax2.text(733183, 1.62, '1.58', weight= 'bold',
alpha=0.8, color = '#ffa500')
ax2.axhline(y=1.26, xmin=0.85, xmax=0.95, alpha=0.5, color ='grey',linestyle='dotted')
ax2.text(733283, 1.25, '1.27', weight= 'bold',
alpha=0.8, color = '#ffa500')
ax2.text(733173, 1.1, '2008', weight= 'bold',
alpha=0.8, color = 'grey')
### Ax3: Post-Crisis
ax3.plot(post_crisis['Time'], post_crisis['rolling_mean'],
color='#00B2EE')
ax3.set_xticklabels([])
#print(ax3.get_xticks())
#print(ax3.get_yticks())
ax3.text(733497, 1.72, 'POST-CRISIS', fontsize=18, weight='bold',
color='#00B2EE')
ax3.text(733497, 1.67, 'Mean 1.389154', weight='bold',
alpha=0.3)
ax3.axhline(y=1.50, xmin=0.80, xmax=0.97, alpha=0.5, color ='grey',linestyle='dotted')
ax3.text(733657, 1.51, '1.49', weight= 'bold',
alpha=0.8, color = '#00B2EE')
ax3.axhline(y=1.26, xmin=0.10, xmax=0.37, alpha=0.5, color ='grey',linestyle='dotted')
ax3.text(733547, 1.26, '1.27', weight= 'bold',
alpha=0.8, color = '#00B2EE')
ax3.text(733577, 1.1, '2009', weight= 'bold',
alpha=0.8, color = 'grey')
### Adding a title and a subtitle
ax.text(732372, 1.95, 'EURO-USD rate behaved differently during crisis vs pre & post',
fontsize=20, weight='bold')
ax.text(732372, 1.85, '''EURO-USD exchange rates Pre, During and Post 2008 crisis''',
fontsize=16)
### Adding a signature
ax.text(732372, 1, 'GM' + ' '*122 + 'Source: European Central Bank',
color = '#f0f0f0', backgroundcolor = '#4d4d4d',
size=14)
plt.show()
### Adding the subplots
plt.figure(figsize=(12, 6))
ax1 = plt.subplot(2,3,1)
ax2 = plt.subplot(2,3,2)
ax3 = plt.subplot(2,3,3)
axes = [ax1, ax2, ax3]
### Changes to all the subplots
for ax in axes:
ax.set_ylim(0.6, 1)
ax.set_yticks([False])
ax.grid(False)
### Ax1: Pre-crisis
ax1.plot(pre_crisisgbp['Time'], pre_crisisgbp['rolling_mean'],
color='#BF5FFF')
ax1.set_xticklabels([])
#print(ax1.get_xticks())
#print(ax1.get_yticks())
ax1.text(732463, 1.05, 'PRE- CRISIS', fontsize=18, weight='bold',
color='#BF5FFF')
ax1.text(732453, 1, 'Mean 0.681875', weight='bold',
alpha=0.3)
ax1.axhline(y=0.72, xmin=0.82, xmax=0.95, alpha=0.5, color ='grey',linestyle='dotted')
ax1.text(732793, 0.715, '0.72', weight= 'bold',
alpha=0.8, color = '#BF5FFF')
ax1.axhline(y=0.65, xmin=0.40, xmax=0.55, alpha=0.5, color ='grey',linestyle='dotted')
ax1.text(732453, 0.63, '0.66', weight= 'bold',
alpha=0.8, color = '#BF5FFF')
ax1.text(732493, 0.55, '2006-2007', weight= 'bold',
alpha=0.8, color = 'grey')
### Ax2: Crisis
ax2.plot(crisisgbp['Time'], crisisgbp['rolling_mean'],
color='#ffa500')
ax2.set_xticklabels([])
#print(ax2.get_xticks())
#print(ax2.get_yticks())
ax2.text(733143, 1.05, 'CRISIS', fontsize=18, weight='bold',
color='#ffa500')
ax2.text(733103, 1, 'Mean 0.785519', weight='bold',
alpha=0.3)
ax2.axhline(y=0.89, xmin=0.85, xmax=0.95, alpha=0.5, color ='grey',linestyle='dotted')
ax2.text(733293, 0.885, '0.89', weight= 'bold',
alpha=0.8, color = '#ffa500')
ax2.axhline(y=0.72, xmin=0.1, xmax=0.25, alpha=0.5, color ='grey',linestyle='dotted')
ax2.text(733133, 0.71, '0.72', weight= 'bold',
alpha=0.8, color = '#ffa500')
ax2.text(733173, 0.55, '2008', weight= 'bold',
alpha=0.8, color = 'grey')
### Ax3: Post-Crisis
ax3.plot(post_crisisgbp['Time'], post_crisisgbp['rolling_mean'],
color='#00B2EE')
ax3.set_xticklabels([])
#print(ax3.get_xticks())
#print(ax3.get_yticks())
ax3.text(733497, 1.05, 'POST-CRISIS', fontsize=18, weight='bold',
color='#00B2EE')
ax3.text(733497, 1, 'Mean 0.891640', weight='bold',
alpha=0.3)
ax3.axhline(y=0.93, xmin=0.1, xmax=0.25, alpha=0.5, color ='grey',linestyle='dotted')
ax3.text(733507, 0.925, '0.93', weight= 'bold',
alpha=0.8, color = '#00B2EE')
ax3.axhline(y=0.86, xmin=0.3, xmax=0.55, alpha=0.5, color ='grey',linestyle='dotted')
ax3.text(733437, 0.86, '0.86', weight= 'bold',
alpha=0.8, color = '#00B2EE')
ax3.text(733577, 0.58, '2009', weight= 'bold',
alpha=0.8, color = 'grey')
### Adding a title and a subtitle
ax.text(732372, 1.22, 'EURO-GBP rate behaved differently during crisis vs pre & post',
fontsize=20, weight='bold')
ax.text(732372, 1.17, '''EURO-GBP exchange rates Pre, During and Post 2008 crisis''',
fontsize=16)
### Adding a signature
ax.text(732372, 0.45, 'GM' + ' '*122 + 'Source: European Central Bank',
color = '#f0f0f0', backgroundcolor = '#4d4d4d',
size=14)
plt.show()
### Adding the subplots
plt.figure(figsize=(12, 6))
ax1 = plt.subplot(2,3,1)
ax2 = plt.subplot(2,3,2)
ax3 = plt.subplot(2,3,3)
axes = [ax1, ax2, ax3]
### Changes to all the subplots
for ax in axes:
ax.set_ylim(1.3, 1.7)
ax.set_yticks([False])
ax.grid(False)
### Ax1: Pre-crisis
ax1.plot(pre_crisischf['Time'], pre_crisischf['rolling_mean'],
color='#BF5FFF')
ax1.set_xticklabels([])
#print(ax1.get_xticks())
#print(ax1.get_yticks())
ax1.text(732463, 1.8, 'PRE- CRISIS', fontsize=18, weight='bold',
color='#BF5FFF')
ax1.text(732453, 1.75, 'Mean 1.604720', weight='bold',
alpha=0.3)
ax1.axhline(y=1.545, xmin=0.1, xmax=0.25, alpha=0.5, color ='grey',linestyle='dotted')
ax1.text(732533, 1.535, '1.55', weight= 'bold',
alpha=0.8, color = '#BF5FFF')
ax1.axhline(y=1.675, xmin=0.75, xmax=0.9, alpha=0.5, color ='grey',linestyle='dotted')
ax1.text(732753, 1.665, '1.67', weight= 'bold',
alpha=0.8, color = '#BF5FFF')
ax1.text(732493, 1.4, '2006-2007', weight= 'bold',
alpha=0.8, color = 'grey')
### Ax2: Crisis
ax2.plot(crisischf['Time'], crisischf['rolling_mean'],
color='#ffa500')
ax2.set_xticklabels([])
#print(ax2.get_xticks())
#print(ax2.get_yticks())
ax2.text(733143, 1.8, 'CRISIS', fontsize=18, weight='bold',
color='#ffa500')
ax2.text(733103, 1.75, 'Mean 1.594302', weight='bold',
alpha=0.3)
ax2.axhline(y=1.50, xmin=0.70, xmax=0.85, alpha=0.5, color ='grey',linestyle='dotted')
ax2.text(733223, 1.50, '1.50', weight= 'bold',
alpha=0.8, color = '#ffa500')
ax2.axhline(y=1.661, xmin=0.05, xmax=0.2, alpha=0.5, color ='grey',linestyle='dotted')
ax2.text(733113, 1.655, '1.65', weight= 'bold',
alpha=0.8, color = '#ffa500')
ax2.text(733173, 1.4, '2008', weight= 'bold',
alpha=0.8, color = 'grey')
### Ax3: Post-Crisis
ax3.plot(post_crisischf['Time'], post_crisischf['rolling_mean'],
color='#00B2EE')
ax3.set_xticklabels([])
#print(ax3.get_xticks())
#print(ax3.get_yticks())
ax3.text(733497, 1.8, 'POST-CRISIS', fontsize=18, weight='bold',
color='#00B2EE')
ax3.text(733497, 1.75, 'Mean 1.512066', weight='bold',
alpha=0.3)
ax3.axhline(y=1.481, xmin=0.2, xmax=0.35, alpha=0.5, color ='grey',linestyle='dotted')
ax3.text(733557, 1.475, '1.48', weight= 'bold',
alpha=0.8, color = '#00B2EE')
ax3.axhline(y=1.54, xmin=0.05, xmax=0.2, alpha=0.5, color ='grey',linestyle='dotted')
ax3.text(733477, 1.54, '1.54', weight= 'bold',
alpha=0.8, color = '#00B2EE')
ax3.text(733577, 1.4, '2009', weight= 'bold',
alpha=0.8, color = 'grey')
### Adding a title and a subtitle
ax.text(732372, 1.95, 'EURO-CHF rate behaved differently during crisis vs pre & post',
fontsize=20, weight='bold')
ax.text(732372, 1.9, '''EURO-CHF exchange rates Pre, During and Post 2008 crisis''',
fontsize=16)
### Adding a signature
ax.text(732372, 1.3, 'GM' + ' '*122 + 'Source: European Central Bank',
color = '#f0f0f0', backgroundcolor = '#4d4d4d',
size=14)
plt.show()