Assignment 4

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 religious events or traditions (see below) for the region of Ann Arbor, Michigan, United States, or United States more broadly.

You can merge these datasets with data from different regions if you like! For instance, you might want to compare Ann Arbor, Michigan, United States to Ann Arbor, USA. In that case at least one source file must be about Ann Arbor, Michigan, United States.

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:

  • State the region and the domain category that your data sets are about (e.g., Ann Arbor, Michigan, United States and religious events or traditions).
  • You must state a question about the domain category and region that you identified as being interesting.
  • You must provide at least two links to available datasets. These could be links to files such as CSV or Excel files, or links to websites which might have data in tabular form, such as Wikipedia pages.
  • You must upload an image which addresses the research question you stated. In addition to addressing the question, this visual should follow Cairo's principles of truthfulness, functionality, beauty, and insightfulness.
  • You must contribute a short (1-2 paragraph) written justification of how your visualization addresses your stated research question.

What do we mean by religious events or traditions? For this category you might consider calendar events, demographic data about religion in the region and neighboring regions, participation in religious events, or how religious events relate to political events, social movements, or historical events.


  • Wikipedia is an excellent source of data, and I strongly encourage you to explore it for new data sources.
  • Many governments run open data initiatives at the city, region, and country levels, and these are wonderful resources for localized data sources.
  • Several international agencies, such as the United Nations, the World Bank, the Global Open Data Index are other great places to look for data.
  • This assignment requires you to convert and clean datafiles. Check out the discussion forums for tips on how to do this from various sources, and share your successes with your fellow students!


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

In [1]:
import pandas as pd
import matplotlib.pyplot as plt

%matplotlib notebook

In [2]:
df_2010 = pd.read_csv('R_2010.csv', sep=";")
df_2000 = pd.read_csv('R_2000.csv', sep=";")
df_1990 = pd.read_csv('R_1990.csv', sep=";")
df_1980 = pd.read_csv('R_1980.csv', sep=";")

FileNotFoundError                         Traceback (most recent call last)
<ipython-input-2-3db45a1c4bf4> in <module>()
----> 1 df_2010 = pd.read_csv('R_2010.csv', sep=";")
      2 df_2000 = pd.read_csv('R_2000.csv', sep=";")
      3 df_1990 = pd.read_csv('R_1990.csv', sep=";")
      4 df_1980 = pd.read_csv('R_1980.csv', sep=";")

/usr/local/lib/python3.5/dist-packages/pandas/io/ in parser_f(filepath_or_buffer, sep, delimiter, header, names, index_col, usecols, squeeze, prefix, mangle_dupe_cols, dtype, engine, converters, true_values, false_values, skipinitialspace, skiprows, nrows, na_values, keep_default_na, na_filter, verbose, skip_blank_lines, parse_dates, infer_datetime_format, keep_date_col, date_parser, dayfirst, iterator, chunksize, compression, thousands, decimal, lineterminator, quotechar, quoting, escapechar, comment, encoding, dialect, tupleize_cols, error_bad_lines, warn_bad_lines, skipfooter, skip_footer, doublequote, delim_whitespace, as_recarray, compact_ints, use_unsigned, low_memory, buffer_lines, memory_map, float_precision)
    653                     skip_blank_lines=skip_blank_lines)
--> 655         return _read(filepath_or_buffer, kwds)
    657     parser_f.__name__ = name

/usr/local/lib/python3.5/dist-packages/pandas/io/ in _read(filepath_or_buffer, kwds)
    404     # Create the parser.
--> 405     parser = TextFileReader(filepath_or_buffer, **kwds)
    407     if chunksize or iterator:

/usr/local/lib/python3.5/dist-packages/pandas/io/ in __init__(self, f, engine, **kwds)
    760             self.options['has_index_names'] = kwds['has_index_names']
--> 762         self._make_engine(self.engine)
    764     def close(self):

/usr/local/lib/python3.5/dist-packages/pandas/io/ in _make_engine(self, engine)
    964     def _make_engine(self, engine='c'):
    965         if engine == 'c':
--> 966             self._engine = CParserWrapper(self.f, **self.options)
    967         else:
    968             if engine == 'python':

/usr/local/lib/python3.5/dist-packages/pandas/io/ in __init__(self, src, **kwds)
   1580         kwds['allow_leading_cols'] = self.index_col is not False
-> 1582         self._reader = parsers.TextReader(src, **kwds)
   1584         # XXX

pandas/_libs/parsers.pyx in pandas._libs.parsers.TextReader.__cinit__ (pandas/_libs/parsers.c:4209)()

pandas/_libs/parsers.pyx in pandas._libs.parsers.TextReader._setup_parser_source (pandas/_libs/parsers.c:8873)()

FileNotFoundError: File b'R_2010.csv' does not exist

In [ ]:

In [ ]:

In [ ]:

In [ ]:

In [ ]:
import functools as ft

dfs = [df_2010, df_2000, df_1990, df_1980]
df = ft.reduce(lambda left,right: pd.merge(left,right,on='Religious Bodies',how='outer',suffixes=('','_nok')), dfs)

# need to get rid of duplicate column names

In [ ]:
df.drop('Tradition_nok', axis=1, inplace=True)
df.drop('Family_nok', axis=1, inplace=True)
df.drop('Congregations_nok', axis=1, inplace=True)

In [ ]:
view1 = df.groupby(['Tradition']).sum()

In [ ]:
columns = ['Adherents 1980','Adherents 1990','Adherents 2000','Adherents 2010']
view1 = view1.reindex(columns=columns)
view1 = view1.rename(columns={'Adherents 1980':'1980', 'Adherents 1990':'1990', 'Adherents 2000':'2000', 'Adherents 2010':'2010'})

In [ ]:
fig =
fig.set_title('Trends of Congregation Adherents 1980-2010')
fig.set_xlabel('Religious Tradition')
plt.xticks(range(view1.shape[0]), view1.index, alpha = 2.5)