{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Problem 1\n", "Import NumPy under the alias `np`." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import numpy as np" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Problem 2\n", "Import pandas under the alias `pd`." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "import pandas as pd" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Problem 3\n", "Using `df1` and `df2` as specified below, merge them using the key `key`. Specify `how = inner` as an argument." ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "df1 = pd.DataFrame({'key': ['foo', 'bar', 'baz', 'foo'],\n", " 'value': [1, 2, 3, 5]})\n", "df2 = pd.DataFrame({'key': ['foo', 'bar', 'baz', 'foo'],\n", " 'value': [5, 6, 7, 8]})" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
keyvalue_xvalue_y
0foo15
1foo18
2foo55
3foo58
4bar26
5baz37
\n", "
" ], "text/plain": [ " key value_x value_y\n", "0 foo 1 5\n", "1 foo 1 8\n", "2 foo 5 5\n", "3 foo 5 8\n", "4 bar 2 6\n", "5 baz 3 7" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#Solution goes here\n", "pd.merge(df1, df2, on='key', how='inner')" ] } ], "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 }