{ "cells": [ { "cell_type": "markdown", "metadata": { "tags": [ "setup" ] }, "source": [ "(c) 2016 - present. Enplus Advisors, Inc." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "tags": [ "setup" ] }, "outputs": [], "source": [ "import numpy as np\n", "import pandas as pd" ] }, { "cell_type": "markdown", "metadata": { "tags": [ "exercise" ] }, "source": [ "**Exercise:**\n", "\n", "* Create a `Series` and assign it to `s1a` from the integers 8, 6, 7, 5\n", "* From a `dict`, create an integer `Series` and assign it to `s1b` with values 8, 6, 7, 5 named `s1b` and a string index 'a', 'b', 'c', and 'd'\n", "* Convert the `s1b` values to 64-bit floating point values and assign it to `s1c`\n", "* Extract only the values from the `s1c` as a `PandasArray`" ] }, { "cell_type": "markdown", "metadata": { "tags": [ "exercise" ] }, "source": [ "**Exercise:**\n", "\n", "* Select the first element of `s2` using integer based lookup (`iloc`).\n", "* Select the first element of the `s2` using label indexing (`loc`).\n", "* Select all elements greater than 6 in `s2` using a boolean `Series`" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "tags": [ "exercise" ] }, "outputs": [], "source": [ "s2 = pd.Series([6, 8, 7, 5], index=list('abcd'), dtype='Int64')" ] }, { "cell_type": "markdown", "metadata": { "tags": [ "exercise" ] }, "source": [ "**Exercise**\n", "\n", "* Select all non-NaN values in `s3`\n", "* What will the result of adding `s2` and `s3` together be? \n", " Figure it out on paper then check in the notebook with `s2 + s3`" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "tags": [ "exercise" ] }, "outputs": [], "source": [ "s3 = pd.Series([9., 100., np.nan], index=list('ayz'), dtype='Int64')" ] } ], "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.7" } }, "nbformat": 4, "nbformat_minor": 4 }