INTRODUCTION AND PROJECT EXPLANATION
The aim of this project is to explore, analyze and visualize the evolution of the exchange rate between the EURO and the US Dollar. Once this is done, I aim to build and visualize a storyline on the evolution of the exchange rate.
At the end of this excercise, I will any insight obtained.
The data used for this project was put together by Daria Chemkaeva and is available at https://www.kaggle.com/datasets/lsind18/euro-exchange-daily-rates-19992020
import pandas as pd
import matplotlib.pyplot as plt
exchange_rates = pd.read_csv("euro-daily-hist_1999_2020.csv")
exchange_rates.head() #Inspection of dataset
Period\Unit: | [Australian dollar ] | [Bulgarian lev ] | [Brazilian real ] | [Canadian dollar ] | [Swiss franc ] | [Chinese yuan renminbi ] | [Cypriot pound ] | [Czech koruna ] | [Danish krone ] | ... | [Romanian leu ] | [Russian rouble ] | [Swedish krona ] | [Singapore dollar ] | [Slovenian tolar ] | [Slovak koruna ] | [Thai baht ] | [Turkish lira ] | [US dollar ] | [South African rand ] | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 2021-01-08 | 1.5758 | 1.9558 | 6.5748 | 1.5543 | 1.0827 | 7.9184 | NaN | 26.163 | 7.4369 | ... | 4.8708 | 90.8000 | 10.0510 | 1.6228 | NaN | NaN | 36.8480 | 9.0146 | 1.2250 | 18.7212 |
1 | 2021-01-07 | 1.5836 | 1.9558 | 6.5172 | 1.5601 | 1.0833 | 7.9392 | NaN | 26.147 | 7.4392 | ... | 4.8712 | 91.2000 | 10.0575 | 1.6253 | NaN | NaN | 36.8590 | 8.9987 | 1.2276 | 18.7919 |
2 | 2021-01-06 | 1.5824 | 1.9558 | 6.5119 | 1.5640 | 1.0821 | 7.9653 | NaN | 26.145 | 7.4393 | ... | 4.8720 | 90.8175 | 10.0653 | 1.6246 | NaN | NaN | 36.9210 | 9.0554 | 1.2338 | 18.5123 |
3 | 2021-01-05 | 1.5927 | 1.9558 | 6.5517 | 1.5651 | 1.0803 | 7.9315 | NaN | 26.227 | 7.4387 | ... | 4.8721 | 91.6715 | 10.0570 | 1.6180 | NaN | NaN | 36.7760 | 9.0694 | 1.2271 | 18.4194 |
4 | 2021-01-04 | 1.5928 | 1.9558 | 6.3241 | 1.5621 | 1.0811 | 7.9484 | NaN | 26.141 | 7.4379 | ... | 4.8713 | 90.3420 | 10.0895 | 1.6198 | NaN | NaN | 36.7280 | 9.0579 | 1.2296 | 17.9214 |
5 rows × 41 columns
exchange_rates.tail() #Inspection of dataset
Period\Unit: | [Australian dollar ] | [Bulgarian lev ] | [Brazilian real ] | [Canadian dollar ] | [Swiss franc ] | [Chinese yuan renminbi ] | [Cypriot pound ] | [Czech koruna ] | [Danish krone ] | ... | [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 | ... | 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 | ... | 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 | ... | 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 | ... | 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 | ... | 1.3111 | 25.2875 | 9.4696 | 1.9554 | 189.0450 | 42.991 | 42.6799 | 0.3723 | 1.1789 | 6.9358 |
5 rows × 41 columns
exchange_rates.info() #Inspection of dataset
<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
Data Cleaning
As I am only focused on the relationship between the Euro and USD over the time span represented in the data, I will clean the USD and "Period\Unit" columns to make the job easier.
exchange_rates.rename(columns={'[US dollar ]': 'US_dollar',
'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)
exchange_rates.head(10) #Inspecting changes made
Time | [Australian dollar ] | [Bulgarian lev ] | [Brazilian real ] | [Canadian dollar ] | [Swiss franc ] | [Chinese yuan renminbi ] | [Cypriot pound ] | [Czech koruna ] | [Danish krone ] | ... | [Romanian leu ] | [Russian rouble ] | [Swedish krona ] | [Singapore dollar ] | [Slovenian tolar ] | [Slovak koruna ] | [Thai baht ] | [Turkish lira ] | US_dollar | [South African rand ] | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 1999-01-04 | 1.9100 | NaN | NaN | 1.8004 | 1.6168 | NaN | 0.58231 | 35.107 | 7.4501 | ... | 1.3111 | 25.2875 | 9.4696 | 1.9554 | 189.0450 | 42.991 | 42.6799 | 0.3723 | 1.1789 | 6.9358 |
1 | 1999-01-05 | 1.8944 | NaN | NaN | 1.7965 | 1.6123 | NaN | 0.58230 | 34.917 | 7.4495 | ... | 1.3168 | 26.5876 | 9.4025 | 1.9655 | 188.7750 | 42.848 | 42.5048 | 0.3728 | 1.1790 | 6.7975 |
2 | 1999-01-06 | 1.8820 | NaN | NaN | 1.7711 | 1.6116 | NaN | 0.58200 | 34.850 | 7.4452 | ... | 1.3168 | 27.4315 | 9.3050 | 1.9699 | 188.7000 | 42.778 | 42.6949 | 0.3722 | 1.1743 | 6.7307 |
3 | 1999-01-07 | 1.8474 | NaN | NaN | 1.7602 | 1.6165 | NaN | 0.58187 | 34.886 | 7.4431 | ... | 1.3092 | 26.9876 | 9.1800 | 1.9436 | 188.8000 | 42.765 | 42.1678 | 0.3701 | 1.1632 | 6.8283 |
4 | 1999-01-08 | 1.8406 | NaN | NaN | 1.7643 | 1.6138 | NaN | 0.58187 | 34.938 | 7.4433 | ... | 1.3143 | 27.2075 | 9.1650 | 1.9537 | 188.8400 | 42.560 | 42.5590 | 0.3718 | 1.1659 | 6.7855 |
5 | 1999-01-11 | 1.8134 | NaN | NaN | 1.7463 | 1.6104 | NaN | 0.58167 | 35.173 | 7.4433 | ... | 1.2980 | 27.0148 | 9.0985 | 1.9358 | 188.9655 | 42.509 | 41.9568 | 0.3725 | 1.1569 | 6.7910 |
6 | 1999-01-12 | 1.8090 | NaN | NaN | 1.7392 | 1.6072 | NaN | 0.58140 | 35.250 | 7.4430 | ... | 1.2912 | 26.6366 | 9.0955 | 1.9343 | 189.5352 | 42.490 | 41.9850 | 0.3721 | 1.1520 | 6.9581 |
7 | 1999-01-13 | 1.8620 | NaN | NaN | 1.8123 | 1.5931 | NaN | 0.58190 | 36.113 | 7.4432 | ... | 1.3149 | 26.4489 | 9.1400 | 1.9815 | 191.2016 | 42.794 | 43.4924 | 0.3764 | 1.1744 | 7.2543 |
8 | 1999-01-14 | 1.8353 | NaN | NaN | 1.7707 | 1.5934 | NaN | 0.58190 | 35.698 | 7.4437 | ... | 1.3134 | 26.5723 | 9.1350 | 1.9615 | 188.9441 | 42.757 | 43.1217 | 0.3751 | 1.1653 | 7.1316 |
9 | 1999-01-15 | 1.8388 | NaN | NaN | 1.7797 | 1.5984 | NaN | 0.58187 | 35.860 | 7.4441 | ... | 1.3164 | 26.5662 | 9.1570 | 1.9570 | 187.1333 | 42.738 | 43.4042 | 0.3742 | 1.1626 | 7.2197 |
10 rows × 41 columns
euro_to_dollar = exchange_rates[["US_dollar", "Time"]] #Now I will isolate the USD values over the years
euro_to_dollar.head() #Inspecting isolated data
US_dollar | Time | |
---|---|---|
0 | 1.1789 | 1999-01-04 |
1 | 1.1790 | 1999-01-05 |
2 | 1.1743 | 1999-01-06 |
3 | 1.1632 | 1999-01-07 |
4 | 1.1659 | 1999-01-08 |
euro_to_dollar["US_dollar"].value_counts()
- 62 1.2276 9 1.1215 8 1.1305 7 1.2713 6 .. 0.9649 1 1.1196 1 1.1309 1 1.0869 1 1.4662 1 Name: US_dollar, Length: 3528, dtype: int64
Rows with entries of "-" must be dropped from the data as they are not useful. The "US_dollar" column must also be converted to the type float.
euro_to_dollar = euro_to_dollar[euro_to_dollar["US_dollar"] != "-"]
euro_to_dollar["US_dollar"].value_counts() #Inspecting changes
1.2276 9 1.1215 8 1.1305 7 1.1218 6 1.1346 6 .. 1.1196 1 1.1309 1 1.0869 1 1.1007 1 1.4662 1 Name: US_dollar, Length: 3527, dtype: int64
euro_to_dollar["US_dollar"] = euro_to_dollar["US_dollar"].astype(float)
euro_to_dollar.info() #Confirmation of changes made
<class 'pandas.core.frame.DataFrame'> Int64Index: 5637 entries, 0 to 5698 Data columns (total 2 columns): # Column Non-Null Count Dtype --- ------ -------------- ----- 0 US_dollar 5637 non-null float64 1 Time 5637 non-null datetime64[ns] dtypes: datetime64[ns](1), float64(1) memory usage: 132.1 KB
import matplotlib.pyplot as plt
%matplotlib inline
VISUALIZING THE DATA
plt.plot(euro_to_dollar["Time"], euro_to_dollar["US_dollar"])
plt.show()
If we observe the graph above, you will notice that we do not have a smooth line, rather, the evolution of the USD in comparison to the Euro is represented by wiggly lines. This is because over the years, the relationship between both currencies evolved on a daily basis.
It will be more beneficial to use a rolling mean to take a closer look at the relationship between both currencies.
Rolling Mean and Rolling Window
To produce clearer and more informed analysis and visualizations, I will be making use of rolling means, which represents the mean of an evolving value over a given period (this period is known as the rolling window).
plt.figure(figsize=(10,8.5))
plt.subplot(3,3,1)
plt.plot(euro_to_dollar["Time"], euro_to_dollar["US_dollar"])
plt.title("Original Version", weight="bold")
rolling_windows = [7,30,100,180,240,365]
subplot_index = [2,3,4,5,6,7]
for window,i in zip(rolling_windows, subplot_index):
plt.subplot(3,3,i)
plt.plot(euro_to_dollar["Time"], euro_to_dollar["US_dollar"].rolling(window).mean())
plt.title("Rolling window:" + str(window), weight="bold")
plt.tight_layout()
plt.show()
The graphs above show that as the rolling window and ultimately the rolling mean increases, there is a clearer representation of the relationship between the USD and the EURO over the years. The next step involves adding the rolling means to the dataset.
for window in rolling_windows:
euro_to_dollar["rolling_mean"+"_"+ str(window)]= euro_to_dollar["US_dollar"].rolling(window).mean().round(4)
euro_to_dollar.head(31) #Inspecting changes made
US_dollar | Time | rolling_mean_7 | rolling_mean_30 | rolling_mean_100 | rolling_mean_180 | rolling_mean_240 | rolling_mean_365 | |
---|---|---|---|---|---|---|---|---|
0 | 1.1789 | 1999-01-04 | NaN | NaN | NaN | NaN | NaN | NaN |
1 | 1.1790 | 1999-01-05 | NaN | NaN | NaN | NaN | NaN | NaN |
2 | 1.1743 | 1999-01-06 | NaN | NaN | NaN | NaN | NaN | NaN |
3 | 1.1632 | 1999-01-07 | NaN | NaN | NaN | NaN | NaN | NaN |
4 | 1.1659 | 1999-01-08 | NaN | NaN | NaN | NaN | NaN | NaN |
5 | 1.1569 | 1999-01-11 | NaN | NaN | NaN | NaN | NaN | NaN |
6 | 1.1520 | 1999-01-12 | 1.1672 | NaN | NaN | NaN | NaN | NaN |
7 | 1.1744 | 1999-01-13 | 1.1665 | NaN | NaN | NaN | NaN | NaN |
8 | 1.1653 | 1999-01-14 | 1.1646 | NaN | NaN | NaN | NaN | NaN |
9 | 1.1626 | 1999-01-15 | 1.1629 | NaN | NaN | NaN | NaN | NaN |
10 | 1.1612 | 1999-01-18 | 1.1626 | NaN | NaN | NaN | NaN | NaN |
11 | 1.1616 | 1999-01-19 | 1.1620 | NaN | NaN | NaN | NaN | NaN |
12 | 1.1575 | 1999-01-20 | 1.1621 | NaN | NaN | NaN | NaN | NaN |
13 | 1.1572 | 1999-01-21 | 1.1628 | NaN | NaN | NaN | NaN | NaN |
14 | 1.1567 | 1999-01-22 | 1.1603 | NaN | NaN | NaN | NaN | NaN |
15 | 1.1584 | 1999-01-25 | 1.1593 | NaN | NaN | NaN | NaN | NaN |
16 | 1.1582 | 1999-01-26 | 1.1587 | NaN | NaN | NaN | NaN | NaN |
17 | 1.1529 | 1999-01-27 | 1.1575 | NaN | NaN | NaN | NaN | NaN |
18 | 1.1410 | 1999-01-28 | 1.1546 | NaN | NaN | NaN | NaN | NaN |
19 | 1.1384 | 1999-01-29 | 1.1518 | NaN | NaN | NaN | NaN | NaN |
20 | 1.1338 | 1999-02-01 | 1.1485 | NaN | NaN | NaN | NaN | NaN |
21 | 1.1337 | 1999-02-02 | 1.1452 | NaN | NaN | NaN | NaN | NaN |
22 | 1.1337 | 1999-02-03 | 1.1417 | NaN | NaN | NaN | NaN | NaN |
23 | 1.1263 | 1999-02-04 | 1.1371 | NaN | NaN | NaN | NaN | NaN |
24 | 1.1292 | 1999-02-05 | 1.1337 | NaN | NaN | NaN | NaN | NaN |
25 | 1.1246 | 1999-02-08 | 1.1314 | NaN | NaN | NaN | NaN | NaN |
26 | 1.1333 | 1999-02-09 | 1.1307 | NaN | NaN | NaN | NaN | NaN |
27 | 1.1342 | 1999-02-10 | 1.1307 | NaN | NaN | NaN | NaN | NaN |
28 | 1.1312 | 1999-02-11 | 1.1304 | NaN | NaN | NaN | NaN | NaN |
29 | 1.1244 | 1999-02-12 | 1.1290 | 1.1507 | NaN | NaN | NaN | NaN |
30 | 1.1238 | 1999-02-15 | 1.1287 | 1.1488 | NaN | NaN | NaN | NaN |
DATA STORYTELLING WITH VISUALIZATIONS
This part of the project involves creating visualizations that tell a story about the relationship between the EURO and the USD over the time span in the dataframe. I have chosen this storyline which my project will revolve around:
The first step of the storytelling process involves defining the years which there was a democrat president and those where there was a republican president.
The second step involves sorting the data to align with the story.
trump = euro_to_dollar[(euro_to_dollar["Time"].dt.year >= 2017)]
bush = euro_to_dollar[(euro_to_dollar["Time"].dt.year < 2009) & (euro_to_dollar["Time"].dt.year >= 2001) ]
clinton =euro_to_dollar[(euro_to_dollar["Time"].dt.year < 2001)]
obama = euro_to_dollar[(euro_to_dollar["Time"].dt.year >= 2009) & (euro_to_dollar["Time"].dt.year < 2017)]
# Plotting the Story
import matplotlib.style as style
style.use("fivethirtyeight")
# Plotting exchange rate from 1999-2021
fig,ax1 = plt.subplots(figsize=(11,5))
ax1.plot(euro_to_dollar["Time"], euro_to_dollar["rolling_mean_30"], linewidth=1, color="#0000FF")
ax1.plot(bush["Time"], bush["rolling_mean_30"], linewidth=3.5, color="#DC143C", label="Republican") #Republican tenure
ax1.plot(trump["Time"], trump["rolling_mean_30"], linewidth=3.5, color="#DC143C") #Republican tenure
ax1.plot(clinton["Time"], clinton["rolling_mean_30"], linewidth=3.5, color="#0000FF", label="Democrat") #Democratic tenure
ax1.plot(obama["Time"], obama["rolling_mean_30"], linewidth=3.5, color="#0000FF") #Democratic tenure
ax1.set_ylim(0.8, 1.8)
ax1.set_yticks([0.8, 1.0, 1.2, 1.4, 1.6, 1.8])
ax1.set_yticklabels(["0.8", "1.0", "1.2","1.4", "1.6", "1.8"], alpha=0.3)
ax1.grid(alpha=0.5)
ax1.text(728000.0, 1.90, "EURO-USD rate from 1999-2021: Emphasis on ruling political party", fontsize=20, weight="bold")
ax1.legend(loc="upper right")
# President Clinton
fig, ax2 = plt.subplots(figsize=(5.25, 2.25))
ax2.plot(clinton["Time"], clinton["rolling_mean_30"], linewidth=3.5, color="#0000FF")
ax2.set_ylim(0.8, 1.2)
ax2.set_yticks([0.8, 1.0, 1.2])
ax2.set_yticklabels(["0.8", "1.0", "1.2"], alpha=0.3)
ax2.grid(alpha=0.5)
ax2.set_xticklabels(["", "1999", ""*10, "2000"], alpha=0.3)
ax2.text(729950.0, 1.25, "CLINTON 99-00", fontsize=18, weight="bold", color="#800080")
# President Bush
fig, ax3 = plt.subplots(figsize=(5.25, 2.25))
ax3.plot(bush["Time"], bush["rolling_mean_30"], linewidth=3.5, color="#DC143C")
ax3.set_ylim(0.8, 1.6)
ax3.set_yticks([0.8, 1.0, 1.2, 1.4, 1.6])
ax3.set_yticklabels(["0.8", "1.0", "1.2","1.4", "1.6"], alpha=0.3)
ax3.grid(alpha=0.5)
ax3.set_xticklabels(["", "2001", "", "2003", "", "2005", "", "2007", "", "2009"], alpha=0.3)
ax3.text(731150.0, 1.72, "BUSH 01-08", fontsize=18, weight="bold", color="#800080")
# President Obama
fig, ax4 = plt.subplots(figsize=(5.25, 2.25))
ax4.plot(obama["Time"], obama["rolling_mean_30"], linewidth=3.5, color="#0000FF")
ax4.set_ylim(1.0, 1.8)
ax4.set_yticks([1.0, 1.2, 1.4, 1.6])
ax4.set_yticklabels(["1.0", "1.2","1.4", "1.6"], alpha=0.3)
ax4.grid(alpha=0.5)
ax4.set_xticklabels(["", "2009", "", "2011", "", "2013", "", "2015", "", "2017"], alpha=0.3)
ax4.text(734000.0, 1.92, "OBAMA 09-17", fontsize=18, weight="bold", color="#800080")
# President Trump
fig, ax5 = plt.subplots(figsize=(5.25, 2.25))
ax5.plot(trump["Time"], trump["rolling_mean_30"], linewidth=3.5, color="#DC143C")
ax5.set_ylim(1.0, 1.4)
ax5.set_yticks([1.0, 1.2, 1.4])
ax5.set_yticklabels(["1.0", "1.2","1.4"], alpha=0.3)
ax5.grid(alpha=0.5)
ax5.set_xticklabels(["2017", "", "2018", "", "2019", "", "2020", "", "2021"], alpha=0.3)
ax5.text(736560.0, 1.5, "TRUMP 17-21", fontsize=18, weight="bold", color="#800080")
plt.show()
AVERAGE VALUE OF USD AGAINST EURO DURING DEMOCRATIC VS REPUBLICAN LEADERSHIP
In order to make a reach a proper conclusion regaarding the exchange rates during democratic vs republican leadership, I must compare the average value of the USD against the Euro during under both leaderships.
It is very important to note that this result is only valid for the data available to me.
# Democratic party
d = len(obama["rolling_mean_30"]) + len(clinton["rolling_mean_30"])
d_avg=((obama["rolling_mean_30"].sum() + clinton["rolling_mean_30"].sum()) / d)
r = len(bush["rolling_mean_30"]) + len(trump["rolling_mean_30"])
r_avg=((bush["rolling_mean_30"].sum() + trump["rolling_mean_30"].sum()) / r)
# Plotting graph to visualize findings
df = pd.DataFrame({"party":['Democratic', 'Republican'], "avg_rate":[d_avg, r_avg]})
plt.bar(df["party"], df["avg_rate"], color=["blue", "red"])
plt.title("Comparing the average rate for converting EURO to USD under Democratic and Republican rule")
plt.show()
ANALYZING FLUCTUATIONS IN EXCHANGE RATE DURING PRESIDENTIAL TENURES
After plotting the visualizations from presidential tenures, I was very interested in finding out which president's tenure had the most volatility in terms of exchange rate. I will be using standard deviation to measure this.
# President Clinton
clinton_std = clinton["rolling_mean_30"].std()
# President Bush
bush_std = bush["rolling_mean_30"].std()
# President Obama
obama_std = obama["rolling_mean_30"].std()
# President Bush
trump_std = trump["rolling_mean_30"].std()
# Visualizing the findings
presidents = ["Clinton", "Bush", "Obama", "Trump"]
std = [clinton_std, bush_std, obama_std, trump_std]
plt.barh(presidents, std, color=["blue", "red", "blue", "red"])
plt.title("Volatility of EURO to USD exchange in relation to presidential tenures", color="grey", fontsize="22")
plt.show()
FINDINGS AND SUMMARY