{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "[Back to PyCampNextLevel Outline](PyCampNextLevel.ipynb)\n", "\n", "# HOME FROM SCHOOL?\n", "\n", "Don't let that keep you behind.\n", "\n", "Lets practice plotting functions to keep in shape!" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "%matplotlib inline" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "[Explain that last command!](https://stackoverflow.com/questions/43027980/purpose-of-matplotlib-inline)" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "def parabola(x):\n", " return x * x" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "domain = np.linspace(-5,5,100) # a 100 points between [5, -5]" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "df = pd.DataFrame({\"domain\":domain, \"range\":[parabola(n) for n in domain]}) # slower" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | domain | \n", "range | \n", "
---|---|---|
0 | \n", "-5.00000 | \n", "25.000000 | \n", "
1 | \n", "-4.89899 | \n", "24.000102 | \n", "
2 | \n", "-4.79798 | \n", "23.020610 | \n", "
3 | \n", "-4.69697 | \n", "22.061524 | \n", "
4 | \n", "-4.59596 | \n", "21.122845 | \n", "