From 389cb76a304348e7f9a01f4f6c87cf9fe30f3e2d Mon Sep 17 00:00:00 2001 From: nehaa Date: Wed, 22 Jul 2020 10:41:50 +0530 Subject: [PATCH 1/2] my initial commit --- assignment1.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 assignment1.txt diff --git a/assignment1.txt b/assignment1.txt new file mode 100644 index 0000000..e69de29 From 8139ec7e14ca6a89b7ce41e14d1940d89385b4f4 Mon Sep 17 00:00:00 2001 From: nehaa Date: Wed, 22 Jul 2020 10:43:49 +0530 Subject: [PATCH 2/2] my initial commit --- assignment1.txt | 125 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 125 insertions(+) diff --git a/assignment1.txt b/assignment1.txt index e69de29..669acda 100644 --- a/assignment1.txt +++ b/assignment1.txt @@ -0,0 +1,125 @@ +import json +import collections +import pandas as pd +import matplotlib.pyplot as plt +import requests + +f = open('data.json') + +data = json.load(f) + +rates = (data['rates']) + +od = collections.OrderedDict(sorted(rates.items())) +datelist = list(od.keys()) + +val = list(rates.values()) + +df = pd.DataFrame(val, index=datelist) + +##################################################### +############# Task 1 T-1 ############################ +##################################################### + +inr = (df.loc[:, 'INR']) +inrval = (list(inr)) + +plt.plot(datelist[:30], inrval[:30]) + +plt.xlabel('Dates') +plt.ylabel('Exchange rates EUR to INR') + +plt.show() + + + + + +plt.xlabel('Dates') +plt.ylabel('Exchange rates EUR to INR') + +plt.show() + +##################################################### +############# Task 2 T-2 ############################ +##################################################### + +gbp = df.loc[:, 'GBP'] +gbpval = list(gbp) + +plt.plot(datelist[:30], gbpval[:30]) + +plt.xlabel('Dates') +plt.ylabel('Exchange rates EUR to INR') + + +plt.show() + + + + +##################################################### +############# Task 3 T-3 ############################ +##################################################### + +response = requests.get("https://api.exchangeratesapi.io/latest") +data = response.json() +latest = dict(data) +rates = latest['rates'] +gbp = rates['GBP'] +inr = rates['INR'] + +plt.plot(datelist[:30], inrval[:30]) +plt.plot(datelist[:30], gbpval[:30]) +plt.xlabel('Dates') +plt.ylabel('Exchange rates EUR to INR') +str1 = "Current value of EUR to INR is " + str(inr) +str2 = "Current value of EUR to GBP is " + str(gbp) +plt.text(3, 8, str1) +plt.text(3, 13, str2) +plt.show() + + + + +##################################################### +############# Feature F-1 ########################### +##################################################### + + +print("Enter the start date (yyyy/mm/dd)") +sdate = input() +print("Enter the end date (yyyy/mm/dd)") +edate = input() + +response = requests.get( + "https://api.exchangeratesapi.io/history?start_at={}&end_at={}".format(sdate, edate)) +data = dict(response.json()) + +data = dict(response.json()) + +rates = data['rates'] +od = collections.OrderedDict(sorted(rates.items())) +datelist = list(od.keys()) + +val = list(rates.values()) + +df = pd.DataFrame(val, index=datelist) + +inr = (df.loc[:, 'INR']) +inrval = (list(inr)) +gbp = df.loc[:, 'GBP'] +gbpval = list(gbp) + +plt.plot(datelist, inrval) + +plt.title("Exchange rate of EUR to INR from {} to {}".format(sdate, edate)) +plt.xlabel('Dates') +plt.ylabel('Exchange rates') + +plt.show() + + + + +