Open doncoding-ai opened 1 year ago
import pandas as pd
exchange_rates = pd.read_csv('euro-daily-hist_1999_2020.csv')
exchange_rates.head()
xchange_rates.tail()
exchange_rates.info()
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()
/euro_to_dollar = exchange_rates[['Time', 'US_dollar']].copy()
euro_to_dollar['US_dollar'].value_counts() # 62 '-' characters
euro_to_dollar = euro_to_dollar[euro_to_dollar['US_dollar'] != '-']
euro_to_dollar['US_dollar'] = euro_to_dollar['US_dollar'].astype(float)
euro_to_dollar.info()
import matplotlib.pyplot as plt
%matplotlib inline
plt.plot(euro_to_dollar['Time'], euro_to_dollar['US_dollar'])
plt.show()
plt.figure(figsize=(9,6))
plt.subplot(3,2,1)
plt.plot(euro_to_dollar['Time'], euro_to_dollar['US_dollar'])
plt.title('Original values', weight='bold')
for i, rolling_mean in zip([2, 3, 4, 5, 6],
[7, 30, 50, 100, 365]):
plt.subplot(3,2,i)
plt.plot(euro_to_dollar['Time'],
euro_to_dollar['US_dollar'].rolling(rolling_mean).mean())
plt.title('Rolling Window:' + str(rolling_mean), weight='bold')
plt.tight_layout() # Auto-adjusts the padding between subplots
plt.show()
euro_to_dollar['rolling_mean'] = euro_to_dollar['US_dollar'].rolling(30).mean()
euro_to_dollar
This a data analysis and visualisation project using python