View in nbviewer
Before working on this assignment please read these instructions fully. In the submission area, you will notice that you can click the link to Preview the Grading for each step of the assignment. This is the criteria that will be used for peer grading. Please familiarize yourself with the criteria before beginning the assignment.
This assignment requires that you to find at least two datasets on the web which are related, and that you visualize these datasets to answer a question with the broad topic of economic activity or measures (see below) for the region of Abu Dhabi, Abu Dhabi, United Arab Emirates, or United Arab Emirates more broadly.
You can merge these datasets with data from different regions if you like! For instance, you might want to compare Abu Dhabi, Abu Dhabi, United Arab Emirates to Ann Arbor, USA. In that case at least one source file must be about Abu Dhabi, Abu Dhabi, United Arab Emirates.
You are welcome to choose datasets at your discretion, but keep in mind they will be shared with your peers, so choose appropriate datasets. Sensitive, confidential, illicit, and proprietary materials are not good choices for datasets for this assignment. You are welcome to upload datasets of your own as well, and link to them using a third party repository such as github, bitbucket, pastebin, etc. Please be aware of the Coursera terms of service with respect to intellectual property.
Also, you are welcome to preserve data in its original language, but for the purposes of grading you should provide english translations. You are welcome to provide multiple visuals in different languages if you would like!
As this assignment is for the whole course, you must incorporate principles discussed in the first week, such as having as high data-ink ratio (Tufte) and aligning with Cairo’s principles of truth, beauty, function, and insight.
Here are the assignment instructions:
What do we mean by economic activity or measures? For this category you might look at the inputs or outputs to the given economy, or major changes in the economy compared to other regions.
Looking for an example? Here's what our course assistant put together for the Ann Arbor, MI, USA area using sports and athletics as the topic. Example Solution File
"""Coursera: python for datascience, matplotlib - Assignment 4 solution"""
%matplotlib notebook
import pandas as pd
import matplotlib.pyplot as plt
from matplotlib.dates import DateFormatter, YearLocator
def gdp_inflation_data(file_name, sheet):
"""Read gdp and inflation data"""
data = pd.read_excel('assignment_data/{}.xlsx'.format(file_name), sheetname=sheet)
data.set_index('year', inplace=True)
if 'inflation_rate' in list(data):
data.inflation_rate = data.inflation_rate*100
data = data.iloc[::-1] # place dates in ascending order
data.index = pd.to_datetime(data.index, format='%Y')
return data
def plot_data():
"""Plot the figure"""
ng_gdp = gdp_inflation_data('data_gdp', 'NG')
ng_inflation = gdp_inflation_data('data_inflation', 'NG')
uae_gdp = gdp_inflation_data('data_gdp', 'UAE')
uae_inflation = gdp_inflation_data('data_inflation', 'UAE')
fig = plt.figure(facecolor='lightblue', figsize=(12, 8))
ax_gdp = plt.subplot(2, 1, 1)
ax_inf = plt.subplot(2, 1, 2, sharex=ax_gdp)
years = YearLocator()
yrfmt = DateFormatter("%Y")
ax_inf.plot_date(ng_inflation.index, ng_inflation.inflation_rate, 'g-o', label='Nigeria')
ax_inf.plot_date(uae_inflation.index, uae_inflation.inflation_rate, 'r-o', label='UAE')
ax_gdp.plot_date(ng_gdp.index, ng_gdp.GDP_bn_dol, 'g-o', label='Nigeria')
ax_gdp.plot_date(uae_gdp.index, uae_gdp.GDP_bn_dol, 'r-o', label='UAE')
ax_gdp.xaxis.set_major_locator(years)
ax_gdp.xaxis.set_major_formatter(yrfmt)
ax_gdp.set(ylabel="GDP (billions of $)")
ax_gdp.autoscale_view()
ax_gdp.legend(loc="upper left")
ax_inf.xaxis.set_major_locator(years)
ax_inf.xaxis.set_major_formatter(yrfmt)
ax_inf.set(ylabel="Inflation rate (in %)")
ax_inf.autoscale_view()
ax_inf.legend(loc="lower left")
title = "Variation of GDP and inflation rate of Nigeria and UAE between 2005 and 2016"
fig.suptitle(title, fontsize=16)
fig.autofmt_xdate()
plt.savefig("output/comparing_gdp_inflation.png", facecolor=fig.get_facecolor(), dpi=100)
plt.savefig("output/comparing_gdp_inflation.pdf", facecolor=fig.get_facecolor(), dpi=100)
plt.show()
plot_data()
C:\Users\Chidimmo\.virtualenvs\ds-UkbacWyt\lib\site-packages\pandas\io\excel.py:329: FutureWarning: The `sheetname` keyword is deprecated, use `sheet_name` instead **kwds)