{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "Before you turn this problem in, make sure everything runs as expected. First, **restart the kernel** (in the menubar, select Kernel$\\rightarrow$Restart) and then **run all cells** (in the menubar, select Cell$\\rightarrow$Run All).\n", "\n", "Make sure you fill in any place that says `YOUR CODE HERE` or \"YOUR ANSWER HERE\", as well as your name and collaborators below:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "NAME = \"\"\n", "COLLABORATORS = \"\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "---" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import os\n", "import os.path\n", "import pandas as pd\n", "\n", "datadir = \"publicdata\"" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Example1: Column Values as a Mashup\n", "\n", "df1 = pd.read_csv(os.path.join(datadir, \"mashup1.csv\"))\n", "df1.head()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# 1. function to extract code\n", "# 2. function to extract country\n", "# 3. apply to get code vector\n", "# 4. apply to get country vector\n", "# 5. drop current country\n", "# 6. add new code and new country\n", "# 7. cleanup on index and column order\n", "\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Example2: Year/Month Mashup/String\n", "\n", "df2 = pd.read_csv(os.path.join(datadir, \"metropolis.csv\"))\n", "df2.head()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Steps?\n", "\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Example3: Multiple rows per country\n", "\n", "df3 = pd.read_csv(os.path.join(datadir, \"mult_rows.csv\"))\n", "df3.head()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# What operation to solve this one?\n", "\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Example4: Multiple rows per country/year combination\n", "\n", "df4 = pd.read_csv(os.path.join(datadir, \"mult_rows2.csv\"))\n", "df4.head()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# What operation(s) to solve this?\n", "\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Example5: Single indicator variable with multiple years\n", "\n", "df5 = pd.read_csv(os.path.join(datadir, \"pop_columns.csv\"))\n", "df5.head()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Steps to resolve??\n", "\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Example6: Multiple indicator variables with multiple years\n", "\n", "df6 = pd.read_csv(os.path.join(datadir, \"popgdp_columns.csv\"))\n", "df6.head()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Steps to resolve??\n", "\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Example7: Two tables for a single mapping\n", "\n", "df7a = pd.read_csv(os.path.join(datadir, \"topfemale.csv\"))\n", "df7b = pd.read_csv(os.path.join(datadir, \"topmale.csv\"))\n", "df7a.head()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "df7b.head()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# How to solve??\n", "\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Example8: One table with multiple mappings\n", "\n", "df8 = pd.read_csv(os.path.join(datadir, \"mixed_table.csv\"))\n", "df8.head()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# How to solve?\n", "\n", "\n" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.6" } }, "nbformat": 4, "nbformat_minor": 4 }