{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## DeLong: Teaching Economics \n", "\n", "Last edited: 2019-10-08" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Introduction: Python \n", "\n", "#### Due ???? via upload to ??? \n", "\n", "### J. Bradford DeLong \n", "\n", " \n", "\n", "You should have gotten to this point vis this link: \n", "\n", " \n", "\n", "This introductory notebook will familiarize you with (some of) the programming tools that will be useful to you. There are many other very good resources for a (gentle) introduction to computer programming. I especially recommend Berkeley's Data 8 website: .\n", "\n", " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Table of Contents \n", "\n", "1. [Computing Environment](#computing_environment): The Jupyter Notebook \n", " 1.1. Markdown Text Cells \n", " 1.2. Python Code Cells \n", " 1.3. The Python Kernel \n", " 1.4. Questions and Exercises \n", " 1.5. Writing Jupyter Notebooks \n", " 1.6. Errors \n", " 1.7. Libraries Check\n", "2. [Introduction to Python Programming Concepts](#programming_concepts)\n", " 2.1. [Basics: The Kernel](#python_basics) \n", " 2.2. Basics: Numbers \n", " 2. [Python and OOP](#Python_and_OOP)\n", " 3. [Pandas](#pandas)\n", " 4. [Visualization](#viz)\n", " 5. [Building Classes](#Building_Classes)\n", " \n", " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 1. Our Computing Environment: The Jupyter Notebook \n", "This webpage is called a Jupyter notebook. A notebook is a place to write programs and view their results. \n", "\n", " \n", "\n", "### 1.1. Markdown Text Cells \n", "\n", "In a notebook, each box containing text or code is called a *cell*.\n", "\n", "Text cells (like this one) can be edited by double-clicking on them to make them the active cell. The formatting is then stripped, leaving an unformatted text string, and a blue or green bar appears on the right. You can then edit the text stream. The text in these cells written in a simple format called [Markdown](http://daringfireball.net/projects/markdown/syntax). You almost surely want to learn Markdown.\n", "\n", "After you edit a text cell, click the \"run cell\" button at the top that looks like ▶| to invoke the Markdown processor on the changed cell, and display the formatted version. (Try not to delete any of the instructions about what you should do.)\n", "\n", "Notice any dollar signs in the unformatted text stream? Those tell the formatting processor that the symbols between the dollar signs make up a mathematical expression written in another not-so-simple format called [LaTeX](https://en.wikipedia.org/wiki/LaTeX). For example:\n", "\n", ">(3.8) $ y^{*mal} = \\phi y^{sub} \\left( 1 + \\frac{ \\gamma h}{\\beta}\\right) $\n", "\n", ">(3.14) $ L_t^{*mal} = \\left[ \\left( \\frac{H_t}{y^{sub}} \\right) \\left( \\frac{s}{\\delta} \\right)^\\theta \\left( \\frac{1}{\\phi} \\right) \\left[ \\frac{1}{(1+\\gamma h/\\delta)^\\theta} \\frac{1}{(1+\\gamma h/\\beta)} \\right] \\right]^\\gamma $ \n", "\n", "You almost surely want to learn (some of) [LaTeX](https://www.latex-project.org) as well. (Jupyter notebooks use only a small subset of LaTex, which is a very powerful and complex programming language—it is, in fact, [Turing-complete](https://www.overleaf.com/learn/latex/Articles/LaTeX_is_More_Powerful_than_you_Think_-_Computing_the_Fibonacci_Numbers_and_Turing_Completeness), which means that if you can write a program to compute something in any computer language on any ([classical](http://www.thphys.nuim.ie/staff/joost/TQM/QvC.html)) computer, you can program it in LaTeX as well. For our purposes, full LaTeX is overkill: Markdown and the equation-processing parts of LaTeX do perfectly well.)\n", "\n", " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ ">**Understanding Check 1.1**: This paragraph is in its own text cell. Try editing it so that this sentence is the last sentence in the paragraph, and then click the 'run cell' (▶|) button in the toolbar above. In short, you should move the previous sentence to a positon after this sentence, and then click the 'run cell' (▶|) button.\n", "\n", " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ ">**Note**: You almost surely also want, sometime, to learn something about one of the genius founders of computer science, mid-twentieth century British mathematician Alan Turing. Here are three very good resources:\n", "\n", ">1. **Charles Petzold** (2008): _The Annotated Turing: A Guided Tour Through Alan Turing's Historic Paper on Computability and the Turing Machine_ ...\n", "https://books.google.com › books\n", "Charles Petzold \n", ">2. **Andrew Hodges** (2012) _Alan Turing: The Enigma_ ... \n", ">3. (2014): _The Imitation Game_ \n", "\n", " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 1.2. Python Code Cells \n", "\n", "Other cells contain code in the Python 3 language. You can switch a cell type from 'code' to 'Markdown' or back by selecting the appropriate option in the toolbar above. (Still other cells might contain 'raw' expressions, but we will not use those.) \n", "\n", "To run the code in a code cell, first click on the cell to make it active. The cell should then be highlighted with a little green or blue bar to the left. Next, either press the 'run cell' button (▶|) in the toolbar above, or hold down the `shift` key and press `return` or `enter`.\n", "\n", "Running a code cell will execute all of the code it contains, if this notebook is connected to a Python interpreter and so able to call the Python kernel. " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Try running this cell:" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[1] \"Hello, World!\"\n" ] } ], "source": [ "print(\"Hello, World!\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "And this one:" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "👋, 🌏!\n" ] } ], "source": [ "print(\"\\N{WAVING HAND SIGN}, \\N{EARTH GLOBE ASIA-AUSTRALIA}!\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The fundamental building block of Python code is an expression—something that starts at the left end of a line, and ends with a 'return' character which is not inside any unclosed left parenthesis ('(')), left brace ('{'), or left bracket ('[').\n", "\n", "Code cells can contain multiple expressions.\n", "\n", "When you run a code cell, the successive expressions contained in the lines of code are executed in the order in which they appear. Every `print` expression prints a line. \n", "\n", "Run the next cell and notice the order of the output:" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "First this line,\n", "then the whole 🌍\n", "and then this one.\n" ] } ], "source": [ "print(\"First this line,\")\n", "print(\"then the whole 🌍\")\n", "print(\"and then this one.\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ ">**Understanding Check 1.2**: Change the cell above so that it prints out:\n", "\n", " First print out this line,\n", " and then this one,\n", " and then, finally, the whole 🌏.\n", " \n", " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 1.3. The Python Kernel \n", "\n", "Look at the upper right corner of this window tab. You should say an open circle, and immediately to the left the words 'Python 3'. (If it says something else—like 'R', for example—click on the word or phrase, select 'Python 3' in the popup that appears, and click 'select'. \n", "\n", "If the circle is closed and empty, the Python kernel is idle and ready to execute code. If the circle is filled in, wait a little while. If it does not become clear, either reselect 'Python 3' or click the 'Restart Kernel' item in the 'Kernel' menu at the top of this window.\n", "\n", "Do not be scared should you see a \"Kernel Restarting\" message! Your data and work will still be saved. Once you see \"Kernel Ready\" in a light blue box on the top right of the notebook, you'll be ready to work again. " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "After a kernel restart, however, you will need to rerun any cells in the notebook above the cell you are currently working on if they import programming modules, load data, or carry out calculations with variables.\n", "\n", "Next to every code cell, you'll see some text that says \"In [...]\". Before you run the cell, you'll see \"In [ ]\". When the cell is running, you'll see In [\\*]. If you see an asterisk (\\*) next to a cell that doesn't go away, it's likely that the code inside the cell is taking too long to run, and it might be a good time to interrupt the kernel. When a cell is finished running, you'll see a number inside the brackets, like so: In [1]. The number corresponds to the order in which you run the cells; so, the first cell you run will show a 1 when it's finished running, the second will show a 2, and so on.\n", "\n", "If your kernel seems stuck, your notebook is very slow and unresponsive, or your kernel loses its connection. If this happens, try:\n", "\n", "1. clicking \"Kernel > Interrupt\".\n", "2. clicking \" Kernel > Restart\".\n", "3. If that doesn't help, restart your server. Save your work by clicking \"File > Save and Checkpoint\". Then click \"Kernel > Shutdown Kernel:. Then click \"Kernel > Restart Kernel\". Then, navigate back to the notebook you were working on. If you do this, you will have to run your code cells from the start of your notebook up until where you paused your work.\n", "\n", " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 1.4. Questions and Exercises \n", "\n", "There will be some questions for you in these notebooks. \n", "\n", "For free response questions, write your answers in the provided markdown cell that starts with ANSWER:. Do not change the heading, and write your entire answer in that one cell. \n", "\n", "For questions that are to be answered numerically, there is a code cell that starts with: \n", "\n", " __# ANSWER__ \n", " \n", "and has a line in which there is a variable (like \"X\") currently set to underscores so:\n", "\n", " X = ___\n", " \n", "Replace those underscores with your final answer. It is okay to make other computations in that cell and others, so long as you set the variable to your answer.\n", " \n", " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 1.5. Writing Jupyter Notebooks \n", "\n", "You will use Jupyter notebooks for your own projects or documents. In order for you to make your own notebook, you'll need to create your own cells for text and code.\n", "\n", "To add a cell, click the + button in the menu bar. It'll start out as a text cell. You can change it to a code cell by clicking inside it so it's highlighted, clicking the drop-down box next to the restart (⟳) button in the menu bar, and choosing \"Code\".\n", "\n", " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ ">**Understanding Check 1.3**: Add a code cell below this one. Write code in it that prints out:\n", " \n", " A whole new cell! ♪🌏♪\n", "\n", ">(That musical note symbol is like the Earth symbol. Its long-form name is `\\N{EIGHTH NOTE}`.)\n", "\n", ">Run your cell to verify that it works.\n", "\n", " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 1.6. Errors \n", "\n", "You will make errors. And the computer will tell you when you do. Making programming errors is not a problem. Not taking steps to correct the errors you make will be.\n", "\n", "Python is a language, and like natural human languages, it has rules. It differs from natural language in two important ways:\n", "\n", "1. The rules are *simple*. You can learn most of them in a few weeks and gain reasonable proficiency with the language in a semester.\n", "2. The rules are *rigid*. If you're proficient in a natural language, you can understand a non-proficient speaker, glossing over small mistakes, automatically correcting them, and resolving ambiguities in a sensible way. \n", " * A computer running Python code is not smart enough to do that.\n", " * It will, instead, refuse to carry out any calculations, and send you an error message instead.\n", " * Sometimes (often?) the error message will be several lines long. The line to look at is the last line of the error message: all the lines above the last line are cascading consequences of the first error the computer found; resolve it, and the others may disappear; fail to resolve it, and the others are unfixable.\n", "\n", "Whenever you write code, you will make mistakes. When you run a code cell that has errors, Python will produce error messages to tell you what you did wrong. You will know it is an error because it is in a pink box to call your attention to it. \n", "\n", "Errors are okay. Even—especially—experienced programmers make many errors. Perhaps the best programmers are those who make—and then correct—the most. \n", "\n", "When you make an error, you just have to find the source of the problem, fix it, and move on.\n", "\n", "We have made an error in the next cell. Run it and see what happens:" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "ename": "SyntaxError", "evalue": "unexpected EOF while parsing (, line 1)", "output_type": "error", "traceback": [ "\u001b[0;36m File \u001b[0;32m\"\"\u001b[0;36m, line \u001b[0;32m1\u001b[0m\n\u001b[0;31m print(\"This line is missing something.\"\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m unexpected EOF while parsing\n" ] } ], "source": [ "print(\"This line is missing something.\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "You should see something like this (minus our annotations):\n", "\n", "" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The computer tells you that this is a `SyntaxError`: it is missing something that the computer requires in order to interpret the expression. 'EOF' means \"end of file\". 'unexpected EOF' means that the computer found itself confronted with the end of the cell before everything needed to make a valid expression had been presented to it. Where it needed to find a ')', it found instead the end of the file that the notebook submitted to the Python kernel when you issued the 'run cell' command. \n", "\n", "There's a lot of terminology in programming languages, but You do not need to know all of the vast ocean of programming-language terminology in order to program effectively. When you see a cryptic message like this, you can often fix it—fix 'the bug'—without having to figure out exactly what the message means. \n", "\n", "(If it is not immediately obvious to you, feel free to ask a friend or somebody else in the class: there is a saying in the practice of debugging programs: \"with enough eyeballs, all bugs are shallow\"—meaning that somewhere there is an eyeball attached to a brain which already knows how to immediately solve that bug, you only have to find that eyeball and get it to look at the faulty code).\n", "\n", ">**Note**: in the toolbar, there is the option to click \"Cell > Run All\", which will run all the code cells in this notebook in order _until it hits an error_. When it hits an error, it stops the 'run all' process.\n", "\n", " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ ">**Understanding Check 1.4**: Try to fix the code above so that you can run the cell and see the intended message instead of an error.\n", "\n", " " ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "print(\"This line is missing something.\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 1.7. Libraries Check \n", "\n", "Now that you know something about our computing environment, it is time to move into understanding Python proper. First, however, run the code cell below to ensure all the libraries needed for this notebook are installed:" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Requirement already satisfied: numpy in /Users/delong/anaconda3/lib/python3.6/site-packages\n", "\u001b[33mYou are using pip version 9.0.2, however version 19.2.3 is available.\n", "You should consider upgrading via the 'pip install --upgrade pip' command.\u001b[0m\n", "Requirement already satisfied: pandas in /Users/delong/anaconda3/lib/python3.6/site-packages\n", "Requirement already satisfied: python-dateutil>=2 in /Users/delong/anaconda3/lib/python3.6/site-packages (from pandas)\n", "Requirement already satisfied: pytz>=2011k in /Users/delong/anaconda3/lib/python3.6/site-packages (from pandas)\n", "Requirement already satisfied: numpy>=1.7.0 in /Users/delong/anaconda3/lib/python3.6/site-packages (from pandas)\n", "Requirement already satisfied: six>=1.5 in /Users/delong/anaconda3/lib/python3.6/site-packages (from python-dateutil>=2->pandas)\n", "\u001b[33mYou are using pip version 9.0.2, however version 19.2.3 is available.\n", "You should consider upgrading via the 'pip install --upgrade pip' command.\u001b[0m\n", "Requirement already satisfied: matplotlib in /Users/delong/anaconda3/lib/python3.6/site-packages\n", "Requirement already satisfied: numpy>=1.7.1 in /Users/delong/anaconda3/lib/python3.6/site-packages (from matplotlib)\n", "Requirement already satisfied: six>=1.10 in /Users/delong/anaconda3/lib/python3.6/site-packages (from matplotlib)\n", "Requirement already satisfied: python-dateutil in /Users/delong/anaconda3/lib/python3.6/site-packages (from matplotlib)\n", "Requirement already satisfied: pytz in /Users/delong/anaconda3/lib/python3.6/site-packages (from matplotlib)\n", "Requirement already satisfied: cycler>=0.10 in /Users/delong/anaconda3/lib/python3.6/site-packages (from matplotlib)\n", "Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=1.5.6 in /Users/delong/anaconda3/lib/python3.6/site-packages (from matplotlib)\n", "\u001b[33mYou are using pip version 9.0.2, however version 19.2.3 is available.\n", "You should consider upgrading via the 'pip install --upgrade pip' command.\u001b[0m\n" ] } ], "source": [ "!pip install numpy\n", "!pip install pandas\n", "!pip install matplotlib" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 2. Introduction to Python Programming Concepts " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 2.1. Basics \n", "\n", "The departure point for all programming is the concept of the __expression__. An expression is a combination of variables, operators, and other Python elements that the language interprets and acts upon. Expressions act as a set of instructions to be fed through the interpreter, with the goal of generating specific outcomes. Here are some examples of very basic expressions:" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "4\n", "me and I\n", "me2\n", "144\n" ] } ], "source": [ "# Examples of basic expressions:\n", "\n", "print(2 + 2) # addition\n", "\n", "print('me' + ' and I') # string concatenation \n", "\n", "print(\"me\" + str(2)) # you can print a number with a string if \n", " # you cast the number and so change it into\n", " # type string with 'str()'...\n", "\n", "print(12 ** 2) # exponentiation\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "If instead we had:" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "144" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Examples of basic expressions:\n", "\n", "(2 + 2) # addition\n", "\n", "('me' + ' and I') # string concatenation \n", "\n", "(\"me\" + str(2)) # you can print a number with a string if \n", " # you cast the number and so change it into\n", " # type string with 'str()'...\n", "\n", "(12 ** 2) # exponentiation" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "You will notice that the last expression and only the last in a cell gets printed out below the cell if it has a value. If you want the computer to print more things to your screen, you need to explicitly tell it to `print()` whatever is inside the parentheses.\n", "\n", " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### 2.1.1. Numbers and Arithmetic \n", "\n", "An expression can be as simple as a number object:" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "3.25" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "3.25000" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "or it can be an arithmetic calculation:" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "3946.0" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "24 * 24 - 15/3 + 15**3" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "A great many basic [arithmetic expressions](http://www.inferentialthinking.com/chapters/03/1/expressions.html) are built into Python. \n", "\n", " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### 2.1.2. Variables and Assignment Expressions \n", "\n", "A __variables__ is an object in the computer's memory (in this case, an `integer` object and a `float` object) with a name. We can store a quantity in that object, and then refer to it by its name and use it later. In Python we do this via expressions that are called assignment statements: an equals sign, with the name of the variable we are assigning a value to on the left-hand side of the equal signs, and what we want the value to be on the right-hand side.\n", "\n", "In the example below, `a` and `b` are variables: " ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [], "source": [ "a = 4\n", "b = 10/5" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Notice that when you create a variable object—unlike what you previously saw—it does not print anything out. Our previous expressions did calculations, and then—if the expression is the last in the cell—reports that calculated value. The '=' sign in an object assignment expression redirects that reporting to the object named before the '=' sign. An assignment expression thus has no value to report.\n", "\n", "Once you have assigned a value to a variable, that value is then bound to the variable name. In order to refer to and use that variable and its value, simply type the variable object name that we stored the value under:" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "4.0" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "c=8/2\n", "\n", "c" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Variables are stored within the notebook's environment: once you have stored a variable value in one cell, that value carries over and can be used in all subsequently executed cells—until the kernel restarts, after which you have to rerun all the previously executed code cells to restore the computer's memory environment to its previous working state:\n" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "4\n" ] }, { "data": { "text/plain": [ "6.0" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Notice that 'a' retains its value from the previous \n", "# code cell above—as long as the kernel was not restarted:\n", "\n", "print(a)\n", "a + b" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ ">**Understanding Check 2.1**: See if you can write a series of expressions that creates two new variables called __x__ and __y__ and assigns them values of __10.5__ and __7.2__. Then assign their product to the variable __combo__ and print it:" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "75.60000000000001\n" ] } ], "source": [ "# Fill in the missing lines to complete the expressions.\n", "\n", "# x = 10.5\n", "# y = 7.2\n", "# combo = x * y\n", "# print(combo)\n", "\n", "#..." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " \n", "\n", "#### 2.1.3. List Objects \n", "\n", "Computers have turned out to be useful for vastly more tasks than simply calculations. Data manipulation plays an especially key role. For data manipulation, the most important concept is the type of object killed a __lists__ (plus its more advanced counterpart, a `numpy array`). \n", "\n", "A list object is an ordered collection of other objects, of sub-objects. Lists allow us to store and access groups of variables and other objects for easy access and analysis. \n", "\n", "Check out this [documentation](https://www.tutorialspoint.com/python/python_lists.htm) for an in-depth look at the capabilities of lists. (Yes, a list can contain itself as a sub-object; no, there is no way to create a list of all lists that do not contain themselves.)\n", "\n", "To initialize a list, use brackets. Putting objects separated by commas in between the brackets adds them to the list:" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[]\n", "[1, 3, 6, 'lists', 'are', 'fun', 4]\n" ] } ], "source": [ "# lists...\n", "\n", "lst = [] # an empty list\n", "print(lst)\n", "\n", "\n", "lst = [1, 3, 6, # assigning to a new list to our empty list\n", " 'lists', 'are', \n", " 'fun', \n", " 4] # note how one expression stretches across\n", " # four lines\n", "print(lst)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "To access a value in a list object, count from left to right, starting at zero. Then write the the name of the list, followed by the number of the subobject you wish to access in brackets:" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "6\n" ] } ], "source": [ "# Elements are selected thus:\n", "\n", "example = lst[2] # to select the '6' in the object 'lst'\n", "\n", "print(example)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "There are some subtleties in how Python treats lists. When you assign a list to a variable object, the variable is then a **pointer** to the list object. What does this mean? It means this: " ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "4\n" ] } ], "source": [ "a = [1,2,3] # assign an original list object to variable a\n", "b = a # assign a to variable b; b now points to list a \n", "b[0] = 4 # now we assign a new value to the first subobject \n", " # of b: we assign the value '0' to it\n", " \n", "# What now is the value of a[0]? Is it '1'—our original assignment?\n", "# Or is it '4'—did the reassignment of b[0] also carry over to a[0]?\n", "# In Python, a[0] is now equal to '4'\n", "\n", "print(a[0])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In Python we can use the '+' sign not just to add numbers, but to add an element to a list—these are two very different senses of the word \"add\":" ] }, { "cell_type": "code", "execution_count": 21, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "example_list is: [1, 2]\n", "example_number is: 3\n" ] } ], "source": [ "# adding an element to a list\n", "\n", "example_list = [1]\n", "example_list = example_list + [2]\n", "print(\"example_list is:\", example_list)\n", "\n", "example_number = 1\n", "example_number = example_number + 2\n", "print(\"example_number is:\", example_number)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "I think that this use of '+' for two different things, addition and concatenation, is a design flaw in Python. But that ship has long ago sailed. You _will_ need to check, when reading and writing Python, whether each '+' is \"add\" in the sense of \"add two numbers\", or \"add\" in the sense of \"add an extra object to a collection\".\n", "\n", " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##### **2.1.3.1. Slicing Lists** \n", "\n", "As you can see from above, lists do not have to be made up of elements of the same kind. Indices do not have to be taken one at a time, either. Instead, we can take a slice of indices and return the elements at those indices as a separate list." ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[3, 6, 'lists']" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# This line will store the 1st (inclusive),\n", "# i.e., not including the 0th element!,\n", "# through 4th (exclusive) elements of lst \n", "# as a new list called lst_2:\n", "\n", "lst_2 = lst[1:4]\n", "\n", "lst_2" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Why does Python use zero-based indexing? Why is the first element of the list 'lst' the 0th, 'lst[0] = 1', rather than the 1st, 'lst[1] = 3', element? This may confuse you, and it may be easier to remember how Python works if you think of Python lists like days of the week. Suppose we have the list:\n", "\n", " days_of_the_week = [Monday, Tuesday, Wednesday, Thursday, Friday]\n", " \n", "What is two days from now, Monday? Wednesday. What is one day from now? Tuesday. Today is Monday—and Monday is not one day from now. Python works the same way.\n", "\n", " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ ">**Understanding Check 2.2: Slicing Lists**: Build a list of length 10 containing whatever elements you'd like. Then, slice it into a new list of length five using a index slicing. Finally, assign the last element in your sliced list to the given variable and print it." ] }, { "cell_type": "code", "execution_count": 15, "metadata": { "scrolled": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "6\n" ] } ], "source": [ "# Fill in the ellipses to complete the question.\n", "\n", "# lst=...\n", "# lst2=lst[...:...]\n", "# a=lst2[...]\n", "\n", "print(a)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Lists can also be operated on with a few built-in analysis functions. These include `min` and `max`, among others. Lists can also be concatenated together. Find some examples below." ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Max of a_list: 13\n", "Min of b_list: 1\n", "Concatenated: [1, 6, 4, 8, 13, 2, 4, 5, 2, 14, 9, 11]\n" ] } ], "source": [ "# MOAR List Examples:\n", "\n", "a_list = [1, 6, 4, 8, 13, 2] # a list containing six integers\n", "\n", "\n", "b_list = [4, 5, 2, 14, 9, 11] # another list containing six integers.\n", "\n", "print('Max of a_list:', max(a_list))\n", "print('Min of b_list:', min(a_list))\n", "\n", "c_list = a_list + b_list # concatenate a_list and b_list\n", "\n", "print('Concatenated:', c_list)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " \n", "\n", "##### **2.1.3.2. Numpy Arrays** \n", "\n", "Python list objects are very flexible and powerful, but they are slow. And even though our computer hardware is immensely powerful, it is not quite powerful enough, sometimes, for the uses we wish to make of it in the environments we want to work in. Therefore there is an add-on library to Python, [__numpy__](https://docs.scipy.org/doc/numpy/reference/routines.html), for \"numerical Python\", to work faster. And there is an object type in numpy, the __array__. A __numpy array__ is a kind of list, in which we know that all of the subobjects—elements—of the array will be numbers, and so the computer can can operate on them much more quickly.\n", "\n", "We tell the computer that we want to use the numpy library with an import statement:" ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [], "source": [ "import numpy as np" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "It is conventional to use the abbreviation 'np' to call on numpy. Whenever, in any Python program, you see an 'np.', you can safely assume that somewhere earlier in the computer's workflow there was a:\n", "\n", " import numpy as np\n", "\n", "Now let's take a look at some things we can do with numpy array objects:" ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Undoubled Array:\n", "[0 1 2 3 4 5 6 7 8 9]\n", "Doubled Array:\n", "[ 0 2 4 6 8 10 12 14 16 18]\n" ] } ], "source": [ "# Initialize an array of integers 0 through 9.\n", "example_array = np.array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])\n", "\n", "# This can also be accomplished using np.arange\n", "example_array_2 = np.arange(10)\n", "print('Undoubled Array:')\n", "print(example_array_2)\n", "\n", "# Double the values in example_array and print the new array.\n", "double_array = example_array*2\n", "print('Doubled Array:')\n", "print(double_array)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This behavior differs from that of a list. See below what happens if you multiply a list." ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9]" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "example_list = [1, 2, 3, 4, 5, 6, 7, 8, 9]\n", "example_list * 2" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Notice that instead of multiplying each of the elements by two, multiplying a list and a number returns that many copies of that list. Other mathematical operations also have... interesting... behaviors with lists. Beware, but also explore.\n", "\n", " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 2.2. How to Program \n", "\n", "#### 2.2.1. The Write-Check-Rewrite Loop \n", "\n", "The computer does not think and work like you do. You can very easily get wrong ideas into your head about what the computer will do in response to the lines of code you type and run, and then fixing your code will become next to impossible unless you work in small, discrete steps. Therefore: write a line of code; run it; check it to make sure it did what you thought it would do; fix it; rerun it; and check it again.\n", "\n", "We will sometimes use the \"ok\" grader to help you see whether you have coded correctly.\n", "\n", "Go ahead and attempt Understnding Check 2.2. Running the cell directly after it will test whether you have assigned `seconds_in_a_decade` correctly. If you haven't, this test will tell you the correct answer. Resist the urge to just copy it, and instead try to adjust your expression. (Sometimes the tests will give hints about what went wrong...)\n", "\n", " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ ">**Understanding Check 2.2**: Assign the name seconds_in_a_decade to the number of seconds between midnight January 1, 2010 and midnight January 1, 2020. Note that there are two leap years in this span of a decade. A non-leap year has 365 days and a leap year has 366 days." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Change the next line \n", "# so that it computes the number of seconds in a decade \n", "# and assigns that number the name, seconds_in_a_decade.\n", "\n", "seconds_in_a_decade = ...\n", "\n", "# seconds_in_a_decade = 60*60*24*(365*10+1+1)\n", "\n", "# We've put this line in this cell \n", "# so that it will print the value you've given to seconds_in_a_decade when you run it. \n", "# You don't need to change this.\n", "\n", "seconds_in_a_decade" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "ok.grade(\"q22\");" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " \n", "\n", "#### 2.2.2. Comments \n", "\n", "You may have noticed lines like these in the code cells so far:\n", "\n", " # Change the next line \n", " # so that it computes the number of seconds in a decade \n", " # and assigns that number the name, seconds_in_a_decade.\n", "\n", "These are comment. Comments do not make anything happen in Python: Python ignores anything on a line after a #. \n", "\n", "Comments are there to communicate something about the code to you, the human reader. Comments are essential if anybody else is to understand your code, and in this case \"anybody else\" includes you a season, a month, a week, and possibly a day from now.\n", "\n", " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### 2.2.3. Programming Dos and Don'ts... \n", "\n", "1. Do restart your kernel and run cells up to your current working point every fifteen minutes or so. Yes, it takes a little time. But if you don't, sooner or later the machine's namespace will get confused, and then you will get confused about the state of the machine's namespace, and by assuming things about it that are false you will lose hours and hours...\n", " \n", "2. Do reload the page when restarting the kernel does not seem to do the job...\n", " \n", "3. Do edit code cells by copying them below your current version and then working on the copy: when you break everything in the current cell (as you will), you can then go back to the old cell and start fresh...\n", " \n", "4. Do exercise \"agile\" development practices: if there is a line of code that you have not tested, test it. The best way to test is to ask the machine to echo back to you the thing you have just created in its namespace to make sure that it is what you want it to be. Only after you are certain that your namespace contains what you think it does should you write the next line of code. And then you should immediately test it...\n", " \n", "5. Do take screenshots of your error messages...\n", " \n", "6. Do google your error messages: Ms. Google is your best friend here...\n", " \n", "7. Do not confuse assignment (\"=\") and test for equality (\"==\"). In general, if there is an \"if\" anywhere nearby, you should be testing for equality. If there is not, you should be assignment a variable in your namespace to a value. Do curse the mathematicians 500 years ago who did not realize that in the twenty-first century it would be very convenient if we had different and not confusable symbols for equals-as-assignment and equals-as-test...\n", "\n", "8. Do expect things to go wrong: it's not the end of the world, or even a threat to your soul. Back up to a stage where things were working as expected, and then try to figure out why things diverged from your expectations. This happens to everybody. \n", "  \n", "Here, for example, we have Gandalf the Grey, Python νB, confronting unexpected behavior from a Python pandas.DataFrame. Yes, he is going to have to upgrade his entire system and reboot. But in the end he will be fine: \n", "\n", "\"Tools\n", "\n", ">**Note**: On the elective affinity between computer programming and sorcery: \n", "\n", " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 2.3. Higher-Order Computer Language Structures \n", "\n", "#### 2.3.1. Background \n", "\n", "At the bottom-most level, a computer is a collection of electronic circuits in which there is either power—understood as a '1'—or no power—understood as a '0'. These circuits are groups into sets of 8—a 'byte'—which is then understood as an 8-digit binary number, something between 0 and 127 (decimal) inclusive. In modern computers these bytes are gathered in groups of 8 into 'words'. The computer then takes these words and adds, negates, and moves them within its systems in accordance with a pattern set by the interaction of the computer's hardware design and the word currently in the computer's _instruction register_.\n", "\n", "But working directly with a computer—programming \"on the bare metal\"—is impossible for humans. At the bare-metal level, a computer can do things like:\n", "\n", "* move a number into a particular memory location or a register (MOV),\n", "* add a number to a register (ADD),\n", "* negate a number (NOT), \n", "* compare two registers and set the flag if they are equal (CMP), * change the next memory location to be read into the instruction register if the flag is set (JIF), \n", "* and a few other things.\n", "\n", "So we build _programming languages_ that translate our ideas about what the computer should do into a pattern of machine-language instructions that the computer can load into its instruction register and work with. And it is essential that such programming languages allow us to work not with raw 8-bit or 64-bit binary numbers but instead with _objects_. Early programming languages set up only four kinds of objects: you could ask the interpreter or compiler that took your program and translated it into machine language to set things up so that some of the numbers in the computer memory could represent integers, others could represent numbers with a fractional part, still others could represent _strings_ of symbols like letters, and still others could represent sets of _operations_—combinations of the basic instruction operations.\n", "\n", ">**Note**: You probably want to learn a little—but only a little—about how what you write in your code cells is translated into dancing electrons. I recommend reading **Charles Petzold** (1999): _Code: The Hidden Language of Computer Hardware and Software_ , starting at the beginning and continuing until you get bored...\n", "\n", "But it very soon became clear—in fact, at the start of computer science it was obvious—that having only these four kinds of objects was inadequate. So slightly later computer languages introduced other types of objects. We have already seen lists and arrays. But the most important of the early additional objects was the _loop_—ways of conveniently specifying that a similar calculation was to be done over and over again. Then came the _function_—an easy-to-type and easy-to-remember way of setting up a calculation that you will want to do that has a few inputs, one output, and that you are going to want to do over and over again for different input values. Ultimately, computer science developed the idea that a modern computer language should be **object-oriented**: it should allow you—in fact, attempt to force you—to define and use your own kinds of _objects_ to have whatever features and properties you found conveneint.\n", "\n", "Python is a very modern computer language.\n", "\n", " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### 2.3.2. Loop Objects \n", "\n", "But, first, let us back up to [__loops__](https://www.tutorialspoint.com/python/python_loops.htm). Loops are super useful. If each line of code we wrote were only executed once, programming would be very unproductive. But by repeated execution of sets of statements on slightly different sets of data, we can begin to unlock the potential of computers. \n", "\n", "Python has two major types of loops: __for__ loops and __while__ loops. A for loop does a thing over and over again for different values of a something, whatever it is, that is named immediately after the keyword for. A while loop does a thing over and again while something is true, and stops when that something becomes false.\n", "\n", " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##### **2.3.2.1. While Loops** \n", "\n", "The __while loop__ repeatedly performs operations until a conditional—something that is either __True__ or __False__—is no longer satisfied. You will hear such a conditional thing called a [boolean expression](https://en.wikipedia.org/wiki/Boolean_expression). \n", "\n", "Thirteenth-century Italian mathematician Leonardo Bonacci of Pisa—now called Fibonacci—wrote the _Book of Calculation_: the first European-language (Latin) book showing what Hindu-Arabic numerals could do—how much easier than was possible using Roman numerals it would be to do money-changing, interest-owed, measure-conversion, and other calculations. In his book, he gave an example of how you could calculate the growth of a hypothetical population of rabbits, which followed what we now call the very useful _Fibonacci sequence_, in which the first two numbers are 1 and 1, and each subsequent number is the sum of the preceding two numbers.\n", "\n", "The code cell below uses a while loop to calculate the nth Fibonacci number:" ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "1 1\n", "2 1\n", "3 2\n", "4 3\n", "5 5\n", "6 8\n", "7 13\n", "8 21\n", "9 34\n", "10 55\n", "11 89\n", "12 144\n", "13 233\n", "14 377\n" ] } ], "source": [ "# using a while loop to calculate the nth Fibonacci number\n", "#\n", "# compute the nth Fibonacci number:\n", "\n", "n = 14 # set which sequence number to compute\n", "i = 1\n", "previous_number = 0\n", "current_number = 1\n", "\n", "while i < n+1:\n", " print(i, current_number)\n", " next_number = previous_number + current_number\n", " previous_number = current_number\n", " current_number = next_number\n", " i = i + 1\n", " \n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "That—the fourteenth Fibonacci number—was as far as Leonardo of Pisa got in his calculations in his _Book of Calculation_.\n", "\n", "The program does the calculation he does, but much more quickly. It starts with the zeroth Fibonacci number—0—and the first number—1—set as the values of the variables *previous\\_number* and *current\\_number*, respectively, with the index of the sequence *i* set equal to 1, and with the desired Fibonnaci number to be calculated set to *n*. \n", "\n", "Then the computer calls the while loop object: while the index *i* is less than the desired number *n*, the program prints the current value of the index *i* and the *current\\_number*, sets the *next\\_number* to the sum of the *current\\_number* and the *previous\\_number*, sets the *previous\\_number* equal to the *current\\_number*, sets the *current\\_number* equal to the *next\\_number*, adds one to the index *i*, and then goes back to the top of the loop to check whether *i* is still less than *n*. If it is not, it exits the loop, and the program cell's calulations come to an end.\n", "\n", "If you had told Fibonnaci back in the thirteenth century that in less than 800 years every student could easily learn how to construct a golem that in a split fraction of a second could calculate not the 14th of his numbers (377) but the 1000th:\n", "\n", ">4346655768693745643568852767504062580256466051 \n", "73717804024817290895365554179490518904038798400 \n", "79255169295922593080322634775209689623239873322 \n", "47116164299644090653318793829896964992851600370 \n", "4476137795166849228875\n", "\n", "what would his reaction have been?\n", "\n", " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##### **2.3.2.2. For Loops** \n", "\n", "For loop objects are essential in traversing a list and performing an analogous set of calculations at each element. For example, the great German mathematician and philosopher Gottfried Wilhelm Leibniz (1646-1716) discovered a wonderful formula for 𝜋 as an infinite sum of simple fractions like this:\n", "\n", "> $ \\pi = 4 - \\frac{4}{3} + \\frac{4}{5} - \\frac{4}{7} + \\frac{4}{9} - \\frac{4}{11} + ... $\n", "\n", "We can use for loop objects to, first, calculate the terms of the series; and then to sum them:" ] }, { "cell_type": "code", "execution_count": 30, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "3.140592653839794\n" ] } ], "source": [ "# using Leibnitz's series for π to calculate an approximate value\n", "\n", "n=1000 # for how many terms do we wish to calculate the series?\n", "\n", "#\n", "# set up the terms of Leibnitz's series\n", "\n", "series_terms = [] # start with an empty list to hold the series terms\n", "\n", "for i in range(1,n+1): # for each of the first n terms of the series\n", " series_terms = series_terms + [4*(-1)**(i+1)*1/(2*i-1)] # calculate the series term\n", "\n", "#\n", "# use the terms to calculate an approximation to π\n", "\n", "π_approximation = 0 # start with zero\n", "\n", "for term in series_terms: # for each of the series terms in our list \n", " π_approximation = π_approximation + term # add the series term to our\n", " # approximation to π\n", " \n", "print(π_approximation) # print our approximation to π" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In both of the for loop objects in the above cell, the most important line is the \"for ... in ...\" line. This sets the structure. It tells the computer to step through every element of the object named after the \"in\", perform the indicated operations, and then move on. Once Python has stepped through every element, the computer exists the loop and prints \"π_approximation\"\n", "\n", "Note that the \"i\" and the \"term\" are arbitrary: as variables they have no existence outside of the for loop, and they could be named anything. For example:" ] }, { "cell_type": "code", "execution_count": 31, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "3.140592653839794\n" ] } ], "source": [ "π_approximation = 0 # start with zero\n", "\n", "for rudolph_the_red_nosed_reindeer in series_terms:\n", " π_approximation = π_approximation + rudolph_the_red_nosed_reindeer \n", " \n", "print(π_approximation) # print our approximation to π" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "works exactly the same.\n", "\n", " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Understanding Check 2.3**: In the following cell, partial steps to manipulate an array are included. You must fill in the blanks to accomplish the following:\n", "\n", "1. Iterate over the entire array, checking if each element is a multiple of 5\n", "2. If an element is not a multiple of 5, add 1 to it repeatedly until it is\n", "3. Iterate back over the list and print each element.\n", "\n", "> Hint: To check if an integer `x` is a multiple of `y`, use the modulus operator `%`. Typing `x % y` will return the remainder when `x` is divided by `y`. Therefore, (`x % y != 0`) will return `True` when `y` does not divide `x`, and `False` when it does." ] }, { "cell_type": "code", "execution_count": 24, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[ 15 35 50 0 25 30 20 105 45 15 80]\n" ] } ], "source": [ "import numpy as np\n", "\n", "# Make use of iterators, range, length, while \n", "# loops, and indices to complete this question.\n", "\n", "question_3 = np.array([12, 31, 50, 0, 22, 28, 19, 105, 44, 12, 77])\n", "\n", "# for i in ...:\n", "# while ...:\n", "# question_3[i]+=1 \n", "\n", "# print(question_3)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### 2.3.3. Function Objects \n", "\n", "The loop objects in the previous section are messy. They contain several expressions, and extend over several lines. It would be nice to figure a way to gather all these pieces together, and make it more transparent just why the object exists and what it is good for.\n", "\n", "A programming language, after all, is much more than a means for instructing a computer to perform tasks. It is a way for us to organize our thoughts about the computer and what it is doing: programs *must* be written for people to read as well as for computers to execute. And the most powerful way to enable people to read is for the programing language to rpovide tools by which compound elements can be built, combined, and then named and used as a single unit—as an easily-understood and referenced object.\n", "\n", "Function objects are thus useful when you want to repeat a series of steps in a calculation for multiple different sets of input values, but don't want to type out the steps over and over again. The purpose of function object provides you with an easy-to-type and easy-to-remember way of setting up such a calculation, and the referring to it and adding it to your program cells whenever you wish. \n", "\n", "Many functions are built into Python already; for example, you've already made use of `len()` to retrieve the number of elements in a list. \n", "\n", "You can also write your own functions. At this point you already have the skills to begin to do so. It is good to get into the habit fo writing functions: the major benefit of using functions is that it makes your code much easier for humans to read—and the human who will have the most trouble reading your code is yourself three months from now, when you are trying to study for the final exam.\n", "\n", "Functions generally take a set of __parameters__ (also called inputs), which define the objects they will use when they are run. For example, the `len()` function takes a list or array as its parameter, and returns the length of that list.\n", "\n", "All of the loops we wrote above can be better presented when encapsulated in functions:" ] }, { "cell_type": "code", "execution_count": 35, "metadata": {}, "outputs": [], "source": [ "# a function to calculate the nth Fibonacci number\n", "\n", "def Fibonacci(n):\n", " \"\"\"\n", " compute the nth Fibonacci number\n", " function input: n, the index of the \n", " Fibonacci number to be computed\n", " function output: F_n, the nth Fibonacci\n", " number\n", " \"\"\"\n", " \n", " i = 1\n", " previous_number = 0\n", " current_number = 1\n", "\n", " while i < n+1:\n", " next_number = previous_number + current_number\n", " previous_number = current_number\n", " current_number = next_number\n", " i = i + 1\n", " return previous_number\n", " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Once you have defined this function, you can then, whenever you want, simply calculate the 14th Fibonacci number and store it in a variable—called \"result\", say—by simply invoking:" ] }, { "cell_type": "code", "execution_count": 38, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "377" ] }, "execution_count": 38, "metadata": {}, "output_type": "execute_result" } ], "source": [ "result = Fibonacci(14)\n", "\n", "result" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Or, if Python did not already have a perfectly good π-calculating function already, a function to calculate π using the Leibnitz approximation might be useful:" ] }, { "cell_type": "code", "execution_count": 42, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "3.1414926535900345" ] }, "execution_count": 42, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# a function to calculate the n-term Leibnitz approximation to π \n", "\n", "def Leibnitz_π(n):\n", " \"\"\"\n", " compute the n-term Leibnitz approximation to π\n", " function input: n, the number of terms to be \n", " calculated in the approximation\n", " function output: π_{Ln}\n", " \"\"\"\n", "\n", " series_terms = []\n", "\n", " for i in range(1,n+1):\n", " series_terms = series_terms + [4*(-1)**(i+1)*1/(2*i-1)] \n", "\n", " π_approximation = 0 \n", "\n", " for term in series_terms: \n", " π_approximation = π_approximation + term\n", " \n", " return π_approximation\n", "\n", "result = Leibnitz_π(10000)\n", "\n", "result" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "But Python does, in the \"math\" library:" ] }, { "cell_type": "code", "execution_count": 43, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "3.141592653589793" ] }, "execution_count": 43, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import math as math\n", "math.pi" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Or if we needed a function to test whether a number is prime:" ] }, { "cell_type": "code", "execution_count": 52, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "False" ] }, "execution_count": 52, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# prime number test function\n", "\n", "def is_multiple(m,n):\n", " \"\"\"\n", " is m a multiple of n?\n", " \"\"\"\n", " if (m%n == 0):\n", " return True\n", " else:\n", " return False\n", "\n", "\n", "def is_it_prime(n):\n", " \"\"\"\n", " tests the number n for primality\n", " \"\"\"\n", " for i in range(2, n):\n", " if (is_multiple(n, i)):\n", " return False \n", " break\n", " if (i >= n/2):\n", " return True\n", " break\n", " \n", "is_it_prime(9)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ ">**Note**: The function above uses the `if` statements. Read more about the `if` statement here: .\n", "\n", " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Remember: The principal reason to use functions—and other objects—is to aid in your understanding, not the computer's. The computer does not care: for it, it is all patterns of ones and zeroes. Thus wherever you can make your program easier to read by explicitly using a function, do so.\n", "\n", "For example, there are lots of times when economists want to calculate the marginal utility of spending on something—say, the marginal utility of spending on consumption for a consumer whose attitude toward risk is captured by a constant relative risk aversion parameter γ. The calculation of marginal utility as a function of the current level of consumption c and the CRRA parameter γ is straightforward:\n", "\n", " marg_util = c**(-γ)\n", " \n", "unless $ \\gamma = 1 $, in which case:\n", "\n", " marg_util = 1/c\n", " \n", "So you wind up writing code like:\n", "\n", " if (γ=1):\n", " marg_util = 1/c\n", " else:\n", " marg_util = c**(-γ)\n", " \n", "So why not put it into a function called marginal_utility, so that you will have one line instead of 4, and to remind yourself of what is going on each time you read through your code?" ] }, { "cell_type": "code", "execution_count": 54, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0.04" ] }, "execution_count": 54, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# marginal utility function\n", "\n", "def marginal_utility(c, γ):\n", " \"\"\"\n", " the marginal utility of increasing spending on consumption\n", " for a consumer with a constant-relative risk aversion\n", " parameter γ and a current level of consumption spending c\n", " \"\"\"\n", " if γ == 1:\n", " return 1 / c\n", " else:\n", " return c**(-γ)\n", "\n", "c = 5\n", "γ = 2\n", "\n", "result = marginal_utility(c, γ)\n", "result" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 2.4. Object-Oriented Programming (OOP) \n", "\n", "Python is a modern kind of computer language called \"object oriented\". That means this: in Python, everything is an object that someone has defined and that you can redefine, and you are free to define your own objects as you wish.\n", "\n", " \n", "\n", "#### 2.4.1. Objects \n", "\n", "OK. What does that list paragraph mean, and why does it matter:\n", "\n", "In Python, an object is a collection of data and instructions held in computer memory that consists of:\n", "\n", "1. a name—what you have called it\n", "2. contents—a value or a set of values\n", "3. methods—things you can do to or extract from it that the computer knows how to do by virtue of what you defined the object to be.\n", "\n", "You might think that a Python variable is simply a named box in which you can store a number. And, indeed the variable has a name and does have its value as its contents. But Python knows that a variable is also an object that understands a great many ways you would like to use it. These predefined ways to use it are called \"methods\".\n", "\n", " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### 2.4.2. Methods \n", "\n", "Here are some of the methods that come with a variable object:" ] }, { "cell_type": "code", "execution_count": 55, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "3\n", "6\n", "9\n", "0\n", "1.0\n", "27\n", "3\n", "True\n", "True\n", "3\n", "0\n", "3\n" ] } ], "source": [ "y = 3\n", "\n", "print(y) # value\n", "print(y + y) # add\n", "print(y * y) # multiply\n", "print(y - y) # subtract\n", "print(y/y) # divide\n", "print(y**y) # exponentiate\n", "print(y.__abs__()) # absolute value\n", "print(y.__bool__()) # is it \"true\" (i.e., not zero)?\n", "print(y.__lt__(5)) # is it less than 5?\n", "print(y.real) # real part\n", "print(y.imag) # imaginary part\n", "print(y.conjugate()) # complex conjugate" ] }, { "cell_type": "code", "execution_count": 58, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "(3+2j)\n", "3.0\n", "2.0\n", "(3-2j)\n", "(6+4j)\n", "(5+12j)\n", "0j\n", "(1+0j)\n", "(-5.409738793917678-13.410442370412747j)\n", "3.605551275463989\n", "True\n", "True\n" ] } ], "source": [ "x = 3 + 2j\n", "\n", "print(x) # value\n", "print(x.real) # real part\n", "print(x.imag) # imaginary part\n", "print(x.conjugate()) # complex conjugate\n", "print(x + x) # add\n", "print(x * x) # multiply\n", "print(x - x) # subtract\n", "print(x/x) # divide\n", "print(x**x) # exponentiate\n", "print(x.__abs__()) # absolute value\n", "print(x.__bool__()) # is x \"true\" (i.e., not zero)?\n", "print(y.__lt__(5)) # is it less than 5?" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "You can call the \n", "\n", " dir(y)\n", " \n", "command to see all the methods that Python has associated with the variable y. And suppose that you want more methods attached to one of your objects? Then you can extend the class of object it is, and define your own.\n", "\n", " \n", "\n", "Python has tools for you to figure out what methods an object has. Consider a list object. Does it know how to use the \"append\" method to add another object to it? Let's see:" ] }, { "cell_type": "code", "execution_count": 66, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "university_list is 9 items long\n", "does university list understand the .append method? True\n" ] } ], "source": [ "university_list = ['UC San Diego', 'UC Riverside', 'UC Irvine', 'UC Los Angeles',\n", " 'UC Santa Barbara', 'UC Merced', 'UC Santa Cruz', \n", " 'UC San Francisco', 'UC Davis']\n", "print(\"university_list is\", len(university_list), \"items long\")\n", "print(\"does university list understand the .append method?\", callable(university_list.append))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "So let's add the missing UC campus—the one that Buffy Summers graduated from:" ] }, { "cell_type": "code", "execution_count": 68, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['UC San Diego',\n", " 'UC Riverside',\n", " 'UC Irvine',\n", " 'UC Los Angeles',\n", " 'UC Santa Barbara',\n", " 'UC Merced',\n", " 'UC Santa Cruz',\n", " 'UC San Francisco',\n", " 'UC Davis',\n", " 'UC Sunnydale']" ] }, "execution_count": 68, "metadata": {}, "output_type": "execute_result" } ], "source": [ "university_list.append('UC Sunnydale')\n", "\n", "university_list" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\"university list\" is now a longer list than it was:" ] }, { "cell_type": "code", "execution_count": 69, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "university_list is 10 items long\n" ] } ], "source": [ "print(\"university_list is\", len(university_list), \"items long\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The 9th element of \"university list\" is the character string \"UC Sunnydale\". And that is an object that has its methods:" ] }, { "cell_type": "code", "execution_count": 70, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'UC SUNNYDALE'" ] }, "execution_count": 70, "metadata": {}, "output_type": "execute_result" } ], "source": [ "university_list[9].upper()" ] }, { "cell_type": "code", "execution_count": 71, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'uc sunnydale'" ] }, "execution_count": 71, "metadata": {}, "output_type": "execute_result" } ], "source": [ "university_list[9].lower()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### 2.4.3. Building Your Own Classes ### \n", "\n", "Imagine now you want to write a program with consumers, who can:\n", "\n", "1. hold and spend cash\n", "2. consume goods\n", "3. work and earn cash\n", "\n", "A natural solution in Python would be to create consumers as objects with\n", "\n", "1. data, such as cash on hand\n", "2. methods, such as buy or work that affect this data\n", "\n", "Python makes it easy to do this, by providing you with class definitions that allow you to build objects according to your own specifications." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "A class definition is a blueprint for a particular class of objects (e.g., lists, strings or complex numbers).\n", "It describesWhat kind of data the class stores, and What methods it has for acting on these data. An object or instance is a realization of the class, created from the blueprint. Each instance has its own unique data.\n", "Methods set out in the class definition act on this (and other) data. In Python, the data and methods of an object are collectively referred to as attributes.\n", "Attributes are accessed via “dotted attribute notation”:\n", "`object_name.data`\n", "`object_name.method_name()`" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "x = [1, 5, 4]\n", "x.sort()\n", "x.__class__" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "`x`is an object or instance, created from the definition for Python lists, but with its own particular data.\n", "`x.sort()` and `x.__class__` are two attributes of `x`.\n", "`dir(x)` can be used to view all the attributes of `x`.\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example: A Consumer Class\n", "we’ll build a `Consumer` class with\n", "1. a `wealth` attribute that stores the consumer’s wealth (data)\n", "2. an `earn` method, where earn(y) increments the consumer’s wealth by y\n", "3. a `spend` method, where spend(x) either decreases wealth by x or returns an error if insufficient funds exist" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "import matplotlib.pyplot as plt\n", "%matplotlib inline\n", "\n", "class Consumer:\n", "\n", " def __init__(self, w):\n", " \"Initialize consumer with w dollars of wealth\"\n", " self.wealth = w\n", "\n", " def earn(self, y):\n", " \"The consumer earns y dollars\"\n", " self.wealth += y\n", "\n", " def spend(self, x):\n", " \"The consumer spends x dollars if feasible\"\n", " new_wealth = self.wealth - x\n", " if new_wealth < 0:\n", " print(\"Insufficent funds\")\n", " else:\n", " self.wealth = new_wealth" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "If you look at the Consumer class definition again you’ll see the word `self` throughout the code.\n", "The rules with `self` are that\n", "1. Any instance data should be prepended with `self`\n", "e.g., the `earn` method references `self.wealth` rather than just `wealth`\n", "2. Any method defined within the class should have `self` as its first argument\n", "e.g., `def earn(self, y)` rather than just `def earn(y)`\n", "Any method referenced within the class should be called as `self.method_name`" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Example: The Solow Growth Model\n", "For our next example, let’s write a simple class to implement the Solow growth model.\n", "The Solow growth model is a neoclassical growth model where the amount of capital stock per capita $k_{t}$ evolves according to the rule\n", "$k_{t+1} = \\frac{s z k_t^{\\alpha} + (1 - \\delta) k_t}{1 + n} \\tag{1}$\n", "Here\n", "$s$ is an exogenously given savings rate\n", "$z$ is a productivity parameter\n", "$\\aplha$ is capital’s share of income\n", "$n$ is the population growth rate\n", "$\\delta$ is the depreciation rate\n", "The steady state of the model is the k that solves$\\tag{1}$ when $k_{t+1} = k_t = k$\n", "\n", "Some points of interest in the code are:\n", "1. An instance maintains a record of its current capital stock in the variable `self.k`.\n", "2. The `h` method implements the right-hand side of (1).\n", "3. `update` method uses `h` to update capital as per (1). Notice how inside `update` the reference to the local method `h` is `self.h`.\n", "The methods `steady_state` and `generate_sequence` are fairly self-explanatory" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "class Solow:\n", " r\"\"\"\n", " Implements the Solow growth model with the update rule\n", "\n", " k_{t+1} = [(s z k^α_t) + (1 - δ)k_t] /(1 + n)\n", "\n", " \"\"\"\n", " def __init__(self, n=0.05, # population growth rate\n", " s=0.25, # savings rate\n", " δ=0.1, # depreciation rate\n", " α=0.3, # share of labor\n", " z=2.0, # productivity\n", " k=1.0): # current capital stock\n", "\n", " self.n, self.s, self.δ, self.α, self.z = n, s, δ, α, z\n", " self.k = k\n", "\n", " def h(self):\n", " \"Evaluate the h function\"\n", " # Unpack parameters (get rid of self to simplify notation)\n", " n, s, δ, α, z = self.n, self.s, self.δ, self.α, self.z\n", " # Apply the update rule\n", " return (s * z * self.k**α + (1 - δ) * self.k) / (1 + n)\n", "\n", " def update(self):\n", " \"Update the current state (i.e., the capital stock).\"\n", " self.k = self.h()\n", "\n", " def steady_state(self):\n", " \"Compute the steady state value of capital.\"\n", " # Unpack parameters (get rid of self to simplify notation)\n", " n, s, δ, α, z = self.n, self.s, self.δ, self.α, self.z\n", " # Compute and return steady state\n", " return ((s * z) / (n + δ))**(1 / (1 - α))\n", "\n", " def generate_sequence(self, t):\n", " \"Generate and return a time series of length t\"\n", " path = []\n", " for i in range(t):\n", " path.append(self.k)\n", " self.update()\n", " return path" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Here’s a little program that uses the class to compute time series from two different initial conditions.\n", "The common steady state is also plotted for comparison" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "s1 = Solow()\n", "s2 = Solow(k=8.0)\n", "\n", "T = 60\n", "fig, ax = plt.subplots(figsize=(9, 6))\n", "\n", "# Plot the common steady state value of capital\n", "ax.plot([s1.steady_state()]*T, 'k-', label='steady state')\n", "\n", "# Plot time series for each economy\n", "for s in s1, s2:\n", " lb = f'capital series from initial state {s.k}'\n", " ax.plot(s.generate_sequence(T), 'o-', lw=2, alpha=0.6, label=lb)\n", "\n", "ax.legend()\n", "plt.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Congratulations, you have finished your first assignment for Econ 101B! Run the cell below to submit all of your work. Make sure to check on OK to make sure that it has uploaded." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " \n", "\n", "### 2.5. Pandas Dataframes \n", "\n", "We will be managing our data using \"dataframe\" objects from the [Pandas](http://pandas.pydata.org/pandas-docs/stable/) library, one of the most widely used Python libraries in data science. We need to import \"pandas\", and it is conventional to abbreviate it \"pd\"\n", ";" ] }, { "cell_type": "code", "execution_count": 75, "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "import pandas as pd" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " \n", "\n", "#### 2.5.1 Creating Dataframes \n", "\n", "The rows and columns of a pandas dataframe are essentially a collection of lists stacked on top/next to each other. For example, to store the top 10 movies and their ratings, I could create 10 lists. Each list would contain a movie title and its corresponding rating, and each list would be one row of the Dataframe's data table:" ] }, { "cell_type": "code", "execution_count": 93, "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", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
RatingMovieDate
09.2The Shawshank Redemption1994
19.2The Godfather1972
29.0The Godfather: Part II1974
38.9Pulp Fiction1994
48.9Schindler's List1993
58.9The Lord of the Rings: The Return of the King2003
68.912 Angry Men1957
78.9The Dark Knight2008
88.9Il buono, il brutto, il cattivo1966
98.8The Lord of the Rings: The Fellowship of the Ring2001
\n", "
" ], "text/plain": [ " Rating Movie Date\n", "0 9.2 The Shawshank Redemption 1994\n", "1 9.2 The Godfather 1972\n", "2 9.0 The Godfather: Part II 1974\n", "3 8.9 Pulp Fiction 1994\n", "4 8.9 Schindler's List 1993\n", "5 8.9 The Lord of the Rings: The Return of the King 2003\n", "6 8.9 12 Angry Men 1957\n", "7 8.9 The Dark Knight 2008\n", "8 8.9 Il buono, il brutto, il cattivo 1966\n", "9 8.8 The Lord of the Rings: The Fellowship of the Ring 2001" ] }, "execution_count": 93, "metadata": {}, "output_type": "execute_result" } ], "source": [ "top_10_movies_df = pd.DataFrame(data=np.array(\n", " [[9.2, 'The Shawshank Redemption', 1994],\n", " [9.2, 'The Godfather', 1972],\n", " [9.0, 'The Godfather: Part II', 1974],\n", " [8.9, 'Pulp Fiction', 1994],\n", " [8.9, \"Schindler's List\", 1993],\n", " [8.9, 'The Lord of the Rings: The Return of the King', 2003],\n", " [8.9, '12 Angry Men', 1957],\n", " [8.9, 'The Dark Knight', 2008],\n", " [8.9, 'Il buono, il brutto, il cattivo', 1966],\n", " [8.8, 'The Lord of the Rings: The Fellowship of the Ring',2001]]), \n", " columns=[\"Rating\", \"Movie\", \"Date\"])\n", "\n", "top_10_movies_df" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Alternatively, we could use an object of class \"dictionary\" to store or data. You can think of a list as a way of associating each value with a key which is its place in the list. Thus: " ] }, { "cell_type": "code", "execution_count": 77, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "The Godfather: Part II\n", "1974\n", "9.0\n" ] } ], "source": [ "Godfather_II_list = ['The Godfather: Part II', 1974, 9.0]\n", "\n", "print(\"0:\", Godfather_II_list[0])\n", "print(\"1:\", Godfather_II_list[1])\n", "print(\"2:\", Godfather_II_list[2])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "A dictionary is like a list, but instead of its keys being the numbers 0, 1, 2, 3..., the dictionary's keys can be anything you define:" ] }, { "cell_type": "code", "execution_count": 89, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "title: The Godfather: Part II\n", "date: 1974\n", "rating: 9.0\n" ] } ], "source": [ "Godfather_II_dict = {'title': 'The Godfather: Part II', 'date': 1974, 'rating': 9.0}\n", " \n", "print(\"title:\", Godfather_II_dict['title']) \n", "print(\"date:\", Godfather_II_dict['date'])\n", "print(\"rating:\", Godfather_II_dict['rating'])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In our top 10 movies example, we could create a dictionary that contains three keys: \"Rating\" as the key to a list of the ratings, \"Movie\" as a key to the movie titles, and \"Date\" as a key to the dates:" ] }, { "cell_type": "code", "execution_count": 92, "metadata": {}, "outputs": [], "source": [ "top_10_movies_dict = {\"Rating\" : [9.2, 9.2, 9.0, 8.9, 8.9, 8.9, 8.9, 8.9, 8.9, 8.8], \n", " \"Movie\" : ['The Shawshank Redemption (1994)',\n", " 'The Godfather',\n", " 'The Godfather: Part II',\n", " 'Pulp Fiction',\n", " \"Schindler's List\",\n", " 'The Lord of the Rings: The Return of the King',\n", " '12 Angry Men',\n", " 'The Dark Knight',\n", " 'Il buono, il brutto, il cattivo',\n", " 'The Lord of the Rings: The Fellowship of the Ring'],\n", " \"Date\" : [1994, 1972, 1974, 1994, 1993, 2003, 1957, 2008, 1966, 2001]\n", " }" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now, we can use this dictionary to create a table with columns `Rating`, `Movie`, and `Date`:" ] }, { "cell_type": "code", "execution_count": 94, "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", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
RatingMovieDate
09.2The Shawshank Redemption (1994)1994
19.2The Godfather1972
29.0The Godfather: Part II1974
38.9Pulp Fiction1994
48.9Schindler's List1993
58.9The Lord of the Rings: The Return of the King2003
68.912 Angry Men1957
78.9The Dark Knight2008
88.9Il buono, il brutto, il cattivo1966
98.8The Lord of the Rings: The Fellowship of the Ring2001
\n", "
" ], "text/plain": [ " Rating Movie Date\n", "0 9.2 The Shawshank Redemption (1994) 1994\n", "1 9.2 The Godfather 1972\n", "2 9.0 The Godfather: Part II 1974\n", "3 8.9 Pulp Fiction 1994\n", "4 8.9 Schindler's List 1993\n", "5 8.9 The Lord of the Rings: The Return of the King 2003\n", "6 8.9 12 Angry Men 1957\n", "7 8.9 The Dark Knight 2008\n", "8 8.9 Il buono, il brutto, il cattivo 1966\n", "9 8.8 The Lord of the Rings: The Fellowship of the Ring 2001" ] }, "execution_count": 94, "metadata": {}, "output_type": "execute_result" } ], "source": [ "top_10_movies_df2 = pd.DataFrame(data=top_10_movies_dict, columns=[\"Rating\", \"Movie\", \"Date\"])\n", "top_10_movies_df2" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Both ways produced the same data table, the same dataframe. The list method created the table by using the lists to make up the rows of the table. The dictionary method took the dictionary keys and used them to make up the columns of the table.\n", "\n", " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### 2.5.2. Reading in Dataframes \n", "\n", "Luckily for you, most data tables in this course will be premade by somebody else—and precleaned. Perhaps the most common file type that is used for economic data is a comma-separated-values (.csv). If properly cleaaned, they are easy to read in as pandas dataframes. We will use the \"pd.read_csv\" function, which takes as its one input parameter the url of the csv file you want to turn into a dataframe:" ] }, { "cell_type": "code", "execution_count": 95, "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "\n", "# Run this cell to read in the table\n", "nipa_quarterly_accounts_df = pd.read_csv(\"https://delong.typepad.com/files/quarterly_accounts.csv\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "What has this command done? Let's use the \"head\" method attached to objects in the dataframe class to see:" ] }, { "cell_type": "code", "execution_count": 96, "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", " \n", " \n", " \n", " \n", " \n", " \n", "
YearQuarterReal GDIReal GDPNominal GDP
01947Q11912.51934.5243.1
11947Q21910.91932.3246.3
21947Q31914.01930.3250.1
31947Q41932.01960.7260.3
41948Q11984.41989.5266.2
\n", "
" ], "text/plain": [ " Year Quarter Real GDI Real GDP Nominal GDP\n", "0 1947 Q1 1912.5 1934.5 243.1\n", "1 1947 Q2 1910.9 1932.3 246.3\n", "2 1947 Q3 1914.0 1930.3 250.1\n", "3 1947 Q4 1932.0 1960.7 260.3\n", "4 1948 Q1 1984.4 1989.5 266.2" ] }, "execution_count": 96, "metadata": {}, "output_type": "execute_result" } ], "source": [ "nipa_quarterly_accounts_df.head()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### 2.5.3. Indexing Dataframes \n", "\n", "Oftentimes, tables will contain a lot of extraneous data that muddles our data tables, making it more difficult to quickly and accurately obtain the data we need. To correct for this, we can select out columns or rows that we need by indexing our dataframes. " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The easiest way to index into a table is with square bracket notation. Suppose you wanted to obtain all of the Real GDP data from the data. Using a single pair of square brackets, you could index the table for `\"Real GDP\"`" ] }, { "cell_type": "code", "execution_count": 98, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0 1934.5\n", "1 1932.3\n", "2 1930.3\n", "3 1960.7\n", "4 1989.5\n", "5 2021.9\n", "6 2033.2\n", "7 2035.3\n", "8 2007.5\n", "9 2000.8\n", "10 2022.8\n", "11 2004.7\n", "12 2084.6\n", "13 2147.6\n", "14 2230.4\n", "15 2273.4\n", "16 2304.5\n", "17 2344.5\n", "18 2392.8\n", "19 2398.1\n", "20 2423.5\n", "21 2428.5\n", "22 2446.1\n", "23 2526.4\n", "24 2573.4\n", "25 2593.5\n", "26 2578.9\n", "27 2539.8\n", "28 2528.0\n", "29 2530.7\n", " ... \n", "251 14541.9\n", "252 14604.8\n", "253 14745.9\n", "254 14845.5\n", "255 14939.0\n", "256 14881.3\n", "257 14989.6\n", "258 15021.1\n", "259 15190.3\n", "260 15291.0\n", "261 15362.4\n", "262 15380.8\n", "263 15384.3\n", "264 15491.9\n", "265 15521.6\n", "266 15641.3\n", "267 15793.9\n", "268 15757.6\n", "269 15935.8\n", "270 16139.5\n", "271 16220.2\n", "272 16350.0\n", "273 16460.9\n", "274 16527.6\n", "275 16547.6\n", "276 16571.6\n", "277 16663.5\n", "278 16778.1\n", "279 16851.4\n", "280 16903.2\n", "Name: Real GDP, Length: 281, dtype: float64" ] }, "execution_count": 98, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Run this cell and see what it outputs\n", "nipa_quarterly_accounts_df[\"Real GDP\"]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Notice how the above cell returns an array of all the real GDP values in their original order.\n", "Now, if you wanted to get the first real GDP value from this array, you could index it with another pair of square brackets:" ] }, { "cell_type": "code", "execution_count": 99, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "1934.5" ] }, "execution_count": 99, "metadata": {}, "output_type": "execute_result" } ], "source": [ "nipa_quarterly_accounts_df[\"Real GDP\"][0]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Pandas columns have many of the same properties as numpy arrays. Keep in mind that pandas dataframes, as well as many other data structures, are zero-indexed, meaning indexes start at 0 and end at the number of elements minus one. " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "If you wanted to create a new datatable with select columns from the original table, you can index with double brackets." ] }, { "cell_type": "code", "execution_count": 100, "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", "
YearQuarterReal GDPReal GDI
01947Q11934.51912.5
11947Q21932.31910.9
21947Q31930.31914.0
31947Q41960.71932.0
41948Q11989.51984.4
\n", "
" ], "text/plain": [ " Year Quarter Real GDP Real GDI\n", "0 1947 Q1 1934.5 1912.5\n", "1 1947 Q2 1932.3 1910.9\n", "2 1947 Q3 1930.3 1914.0\n", "3 1947 Q4 1960.7 1932.0\n", "4 1948 Q1 1989.5 1984.4" ] }, "execution_count": 100, "metadata": {}, "output_type": "execute_result" } ], "source": [ "## Note: .head() returns the first five rows of the table\n", "nipa_quarterly_accounts_df[[\"Year\", \"Quarter\", \"Real GDP\", \"Real GDI\"]].head()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "You can get rid of columns you dont need using `.drop()`" ] }, { "cell_type": "code", "execution_count": 104, "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", "
YearQuarterReal GDIReal GDP
01947Q11912.51934.5
11947Q21910.91932.3
21947Q31914.01930.3
31947Q41932.01960.7
41948Q11984.41989.5
\n", "
" ], "text/plain": [ " Year Quarter Real GDI Real GDP\n", "0 1947 Q1 1912.5 1934.5\n", "1 1947 Q2 1910.9 1932.3\n", "2 1947 Q3 1914.0 1930.3\n", "3 1947 Q4 1932.0 1960.7\n", "4 1948 Q1 1984.4 1989.5" ] }, "execution_count": 104, "metadata": {}, "output_type": "execute_result" } ], "source": [ "nipa_quarterly_accounts_df.drop(\"Nominal GDP\", axis=1).head()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Finally, you can use square bracket notation to index rows by their indices. For example, if I wanted the 20th to 30th rows of `accounts`:" ] }, { "cell_type": "code", "execution_count": 106, "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", " \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", " \n", " \n", " \n", " \n", " \n", "
YearQuarterReal GDIReal GDPNominal GDP
201952Q12398.32423.5360.2
211952Q22412.62428.5361.4
221952Q32435.02446.1368.1
231952Q42509.52526.4381.2
241953Q12554.32573.4388.5
251953Q22572.22593.5392.3
261953Q32555.72578.9391.7
271953Q42504.12539.8386.5
281954Q12510.12528.0385.9
291954Q22514.52530.7386.7
301954Q32537.12559.4391.6
\n", "
" ], "text/plain": [ " Year Quarter Real GDI Real GDP Nominal GDP\n", "20 1952 Q1 2398.3 2423.5 360.2\n", "21 1952 Q2 2412.6 2428.5 361.4\n", "22 1952 Q3 2435.0 2446.1 368.1\n", "23 1952 Q4 2509.5 2526.4 381.2\n", "24 1953 Q1 2554.3 2573.4 388.5\n", "25 1953 Q2 2572.2 2593.5 392.3\n", "26 1953 Q3 2555.7 2578.9 391.7\n", "27 1953 Q4 2504.1 2539.8 386.5\n", "28 1954 Q1 2510.1 2528.0 385.9\n", "29 1954 Q2 2514.5 2530.7 386.7\n", "30 1954 Q3 2537.1 2559.4 391.6" ] }, "execution_count": 106, "metadata": {}, "output_type": "execute_result" } ], "source": [ "nipa_quarterly_accounts_df[20:31]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### 2.5.4. Filtering Data \n", "\n", "Indexing rows based on indices is only useful when you know the specific set of rows that you need, and you can only really get a range of entries. Working with data often involves huge datasets, making it inefficient and sometimes impossible to know exactly what indices to be looking at. On top of that, most data analysis concerns itself with looking for patterns or specific conditions in the data, which is impossible to look for with simple index based sorting. " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Thankfully, you can also use square bracket notation to filter out data based on a condition. Suppose we only wanted real GDP and nominal GDP data from the 21st century:" ] }, { "cell_type": "code", "execution_count": 107, "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", " \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", " \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", " \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", " \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", " \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", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
Real GDPNominal GDP
21212359.110031.0
21312592.510278.3
21412607.710357.4
21512679.310472.3
21612643.310508.1
21712710.310638.4
21812670.110639.5
21912705.310701.3
22012822.310834.4
22112893.010934.8
22212955.811037.1
22312964.011103.8
22413031.211230.1
22513152.111370.7
22613372.411625.1
22713528.711816.8
22813606.511988.4
22913706.212181.4
23013830.812367.7
23113950.412562.2
23214099.112813.7
23314172.712974.1
23414291.813205.4
23514373.413381.6
23614546.113648.9
23714589.613799.8
23814602.613908.5
23914716.914066.4
24014726.014233.2
24114838.714422.3
.........
25114541.914566.5
25214604.814681.1
25314745.914888.6
25414845.515057.7
25514939.015230.2
25614881.315238.4
25714989.615460.9
25815021.115587.1
25915190.315785.3
26015291.015973.9
26115362.416121.9
26215380.816227.9
26315384.316297.3
26415491.916475.4
26515521.616541.4
26615641.316749.3
26715793.916999.9
26815757.617031.3
26915935.817320.9
27016139.517622.3
27116220.217735.9
27216350.017874.7
27316460.918093.2
27416527.618227.7
27516547.618287.2
27616571.618325.2
27716663.518538.0
27816778.118729.1
27916851.418905.5
28016903.219057.7
\n", "

69 rows × 2 columns

\n", "
" ], "text/plain": [ " Real GDP Nominal GDP\n", "212 12359.1 10031.0\n", "213 12592.5 10278.3\n", "214 12607.7 10357.4\n", "215 12679.3 10472.3\n", "216 12643.3 10508.1\n", "217 12710.3 10638.4\n", "218 12670.1 10639.5\n", "219 12705.3 10701.3\n", "220 12822.3 10834.4\n", "221 12893.0 10934.8\n", "222 12955.8 11037.1\n", "223 12964.0 11103.8\n", "224 13031.2 11230.1\n", "225 13152.1 11370.7\n", "226 13372.4 11625.1\n", "227 13528.7 11816.8\n", "228 13606.5 11988.4\n", "229 13706.2 12181.4\n", "230 13830.8 12367.7\n", "231 13950.4 12562.2\n", "232 14099.1 12813.7\n", "233 14172.7 12974.1\n", "234 14291.8 13205.4\n", "235 14373.4 13381.6\n", "236 14546.1 13648.9\n", "237 14589.6 13799.8\n", "238 14602.6 13908.5\n", "239 14716.9 14066.4\n", "240 14726.0 14233.2\n", "241 14838.7 14422.3\n", ".. ... ...\n", "251 14541.9 14566.5\n", "252 14604.8 14681.1\n", "253 14745.9 14888.6\n", "254 14845.5 15057.7\n", "255 14939.0 15230.2\n", "256 14881.3 15238.4\n", "257 14989.6 15460.9\n", "258 15021.1 15587.1\n", "259 15190.3 15785.3\n", "260 15291.0 15973.9\n", "261 15362.4 16121.9\n", "262 15380.8 16227.9\n", "263 15384.3 16297.3\n", "264 15491.9 16475.4\n", "265 15521.6 16541.4\n", "266 15641.3 16749.3\n", "267 15793.9 16999.9\n", "268 15757.6 17031.3\n", "269 15935.8 17320.9\n", "270 16139.5 17622.3\n", "271 16220.2 17735.9\n", "272 16350.0 17874.7\n", "273 16460.9 18093.2\n", "274 16527.6 18227.7\n", "275 16547.6 18287.2\n", "276 16571.6 18325.2\n", "277 16663.5 18538.0\n", "278 16778.1 18729.1\n", "279 16851.4 18905.5\n", "280 16903.2 19057.7\n", "\n", "[69 rows x 2 columns]" ] }, "execution_count": 107, "metadata": {}, "output_type": "execute_result" } ], "source": [ "nipa_quarterly_accounts_df[nipa_quarterly_accounts_df[\"Year\"] >= 2000][[\"Real GDP\", \"Nominal GDP\"]]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The `nipa_quarterly_accounts_df` table is being indexed by the condition `nipa_quarterly_accounts_df[\"Year\"] >= 2000`, which returns a table where only rows that have a \"Year\" greater than $2000$ is returned. We then index this table with the double bracket notation from the previous section to only get the real GDP and nominal GDP columns." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Suppose now we wanted a table with data from the first quarter, and where the real GDP was less than 5000 or nominal GDP is greater than 15,000." ] }, { "cell_type": "code", "execution_count": 108, "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", " \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", " \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", " \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", " \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", " \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", "
YearQuarterReal GDIReal GDPNominal GDP
01947Q11912.51934.5243.1
41948Q11984.41989.5266.2
81949Q12001.52007.5275.4
121950Q12060.12084.6281.2
161951Q12281.02304.5336.4
201952Q12398.32423.5360.2
241953Q12554.32573.4388.5
281954Q12510.12528.0385.9
321955Q12661.62683.8413.8
361956Q12775.42770.0440.5
401957Q12862.02854.5470.6
441958Q12779.92772.7468.4
481959Q12976.52976.6511.1
521960Q13121.93123.2543.3
561961Q13109.93102.3545.9
601962Q13328.63336.8595.2
641963Q13469.13456.1622.7
681964Q13658.63672.7671.1
721965Q13885.53873.5719.2
761966Q14167.84201.9797.3
801967Q14286.54324.9846.0
841968Q14465.64490.6911.1
881969Q14665.44691.6995.4
921970Q14690.44707.11053.5
961971Q14778.04834.31137.8
2562011Q114924.414881.315238.4
2602012Q115500.415291.015973.9
2642013Q115642.715491.916475.4
2682014Q115912.815757.617031.3
2722015Q116599.616350.017874.7
2762016Q116776.116571.618325.2
2802017Q116992.116903.219057.7
\n", "
" ], "text/plain": [ " Year Quarter Real GDI Real GDP Nominal GDP\n", "0 1947 Q1 1912.5 1934.5 243.1\n", "4 1948 Q1 1984.4 1989.5 266.2\n", "8 1949 Q1 2001.5 2007.5 275.4\n", "12 1950 Q1 2060.1 2084.6 281.2\n", "16 1951 Q1 2281.0 2304.5 336.4\n", "20 1952 Q1 2398.3 2423.5 360.2\n", "24 1953 Q1 2554.3 2573.4 388.5\n", "28 1954 Q1 2510.1 2528.0 385.9\n", "32 1955 Q1 2661.6 2683.8 413.8\n", "36 1956 Q1 2775.4 2770.0 440.5\n", "40 1957 Q1 2862.0 2854.5 470.6\n", "44 1958 Q1 2779.9 2772.7 468.4\n", "48 1959 Q1 2976.5 2976.6 511.1\n", "52 1960 Q1 3121.9 3123.2 543.3\n", "56 1961 Q1 3109.9 3102.3 545.9\n", "60 1962 Q1 3328.6 3336.8 595.2\n", "64 1963 Q1 3469.1 3456.1 622.7\n", "68 1964 Q1 3658.6 3672.7 671.1\n", "72 1965 Q1 3885.5 3873.5 719.2\n", "76 1966 Q1 4167.8 4201.9 797.3\n", "80 1967 Q1 4286.5 4324.9 846.0\n", "84 1968 Q1 4465.6 4490.6 911.1\n", "88 1969 Q1 4665.4 4691.6 995.4\n", "92 1970 Q1 4690.4 4707.1 1053.5\n", "96 1971 Q1 4778.0 4834.3 1137.8\n", "256 2011 Q1 14924.4 14881.3 15238.4\n", "260 2012 Q1 15500.4 15291.0 15973.9\n", "264 2013 Q1 15642.7 15491.9 16475.4\n", "268 2014 Q1 15912.8 15757.6 17031.3\n", "272 2015 Q1 16599.6 16350.0 17874.7\n", "276 2016 Q1 16776.1 16571.6 18325.2\n", "280 2017 Q1 16992.1 16903.2 19057.7" ] }, "execution_count": 108, "metadata": {}, "output_type": "execute_result" } ], "source": [ "nipa_quarterly_accounts_df[(nipa_quarterly_accounts_df[\"Quarter\"] ==\n", " \"Q1\") & ((nipa_quarterly_accounts_df[\"Real GDP\"] < 5000) | \n", " (nipa_quarterly_accounts_df[\"Nominal GDP\"] > 15000))]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Many different conditions can be included to filter, and you can use `&` and `|` operators to connect them together. Make sure to include parantheses for each condition!" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Another way to reorganize data to make it more convenient is to sort the data by the values in a specific column. For example, if we wanted to find the highest real GDP since 1947, we could sort the table for real GDP:" ] }, { "cell_type": "code", "execution_count": 109, "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", " \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", " \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", " \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", " \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", " \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", " \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", " \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", " \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", " \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", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
YearQuarterReal GDIReal GDPNominal GDP
21947Q31914.01930.3250.1
11947Q21910.91932.3246.3
01947Q11912.51934.5243.1
31947Q41932.01960.7260.3
41948Q11984.41989.5266.2
91949Q21995.92000.8271.7
111949Q41979.62004.7271.0
81949Q12001.52007.5275.4
51948Q22030.22021.9272.9
101949Q32007.92022.8273.3
61948Q32031.52033.2279.5
71948Q42041.62035.3280.7
121950Q12060.12084.6281.2
131950Q22144.42147.6290.7
141950Q32225.92230.4308.5
151950Q42268.92273.4320.3
161951Q12281.02304.5336.4
171951Q22321.32344.5344.5
181951Q32362.02392.8351.8
191951Q42382.72398.1356.6
201952Q12398.32423.5360.2
211952Q22412.62428.5361.4
221952Q32435.02446.1368.1
231952Q42509.52526.4381.2
281954Q12510.12528.0385.9
291954Q22514.52530.7386.7
271953Q42504.12539.8386.5
301954Q32537.12559.4391.6
241953Q12554.32573.4388.5
261953Q32555.72578.9391.7
..................
2442008Q114842.214889.514668.4
2462008Q314767.014891.614843.0
2422007Q314822.414938.514569.7
2552010Q414904.914939.015230.2
2452008Q214832.414963.414813.0
2572011Q214996.114989.615460.9
2432007Q414816.614991.814685.3
2582011Q315093.115021.115587.1
2592011Q415217.015190.315785.3
2602012Q115500.415291.015973.9
2612012Q215522.815362.416121.9
2622012Q315517.115380.816227.9
2632012Q415650.615384.316297.3
2642013Q115642.715491.916475.4
2652013Q215719.815521.616541.4
2662013Q315752.015641.316749.3
2682014Q115912.815757.617031.3
2672013Q415851.315793.916999.9
2692014Q216136.115935.817320.9
2702014Q316327.916139.517622.3
2712014Q416520.816220.217735.9
2722015Q116599.616350.017874.7
2732015Q216700.616460.918093.2
2742015Q316726.716527.618227.7
2752015Q416789.816547.618287.2
2762016Q116776.116571.618325.2
2772016Q216783.016663.518538.0
2782016Q316953.016778.118729.1
2792016Q416882.116851.418905.5
2802017Q116992.116903.219057.7
\n", "

281 rows × 5 columns

\n", "
" ], "text/plain": [ " Year Quarter Real GDI Real GDP Nominal GDP\n", "2 1947 Q3 1914.0 1930.3 250.1\n", "1 1947 Q2 1910.9 1932.3 246.3\n", "0 1947 Q1 1912.5 1934.5 243.1\n", "3 1947 Q4 1932.0 1960.7 260.3\n", "4 1948 Q1 1984.4 1989.5 266.2\n", "9 1949 Q2 1995.9 2000.8 271.7\n", "11 1949 Q4 1979.6 2004.7 271.0\n", "8 1949 Q1 2001.5 2007.5 275.4\n", "5 1948 Q2 2030.2 2021.9 272.9\n", "10 1949 Q3 2007.9 2022.8 273.3\n", "6 1948 Q3 2031.5 2033.2 279.5\n", "7 1948 Q4 2041.6 2035.3 280.7\n", "12 1950 Q1 2060.1 2084.6 281.2\n", "13 1950 Q2 2144.4 2147.6 290.7\n", "14 1950 Q3 2225.9 2230.4 308.5\n", "15 1950 Q4 2268.9 2273.4 320.3\n", "16 1951 Q1 2281.0 2304.5 336.4\n", "17 1951 Q2 2321.3 2344.5 344.5\n", "18 1951 Q3 2362.0 2392.8 351.8\n", "19 1951 Q4 2382.7 2398.1 356.6\n", "20 1952 Q1 2398.3 2423.5 360.2\n", "21 1952 Q2 2412.6 2428.5 361.4\n", "22 1952 Q3 2435.0 2446.1 368.1\n", "23 1952 Q4 2509.5 2526.4 381.2\n", "28 1954 Q1 2510.1 2528.0 385.9\n", "29 1954 Q2 2514.5 2530.7 386.7\n", "27 1953 Q4 2504.1 2539.8 386.5\n", "30 1954 Q3 2537.1 2559.4 391.6\n", "24 1953 Q1 2554.3 2573.4 388.5\n", "26 1953 Q3 2555.7 2578.9 391.7\n", ".. ... ... ... ... ...\n", "244 2008 Q1 14842.2 14889.5 14668.4\n", "246 2008 Q3 14767.0 14891.6 14843.0\n", "242 2007 Q3 14822.4 14938.5 14569.7\n", "255 2010 Q4 14904.9 14939.0 15230.2\n", "245 2008 Q2 14832.4 14963.4 14813.0\n", "257 2011 Q2 14996.1 14989.6 15460.9\n", "243 2007 Q4 14816.6 14991.8 14685.3\n", "258 2011 Q3 15093.1 15021.1 15587.1\n", "259 2011 Q4 15217.0 15190.3 15785.3\n", "260 2012 Q1 15500.4 15291.0 15973.9\n", "261 2012 Q2 15522.8 15362.4 16121.9\n", "262 2012 Q3 15517.1 15380.8 16227.9\n", "263 2012 Q4 15650.6 15384.3 16297.3\n", "264 2013 Q1 15642.7 15491.9 16475.4\n", "265 2013 Q2 15719.8 15521.6 16541.4\n", "266 2013 Q3 15752.0 15641.3 16749.3\n", "268 2014 Q1 15912.8 15757.6 17031.3\n", "267 2013 Q4 15851.3 15793.9 16999.9\n", "269 2014 Q2 16136.1 15935.8 17320.9\n", "270 2014 Q3 16327.9 16139.5 17622.3\n", "271 2014 Q4 16520.8 16220.2 17735.9\n", "272 2015 Q1 16599.6 16350.0 17874.7\n", "273 2015 Q2 16700.6 16460.9 18093.2\n", "274 2015 Q3 16726.7 16527.6 18227.7\n", "275 2015 Q4 16789.8 16547.6 18287.2\n", "276 2016 Q1 16776.1 16571.6 18325.2\n", "277 2016 Q2 16783.0 16663.5 18538.0\n", "278 2016 Q3 16953.0 16778.1 18729.1\n", "279 2016 Q4 16882.1 16851.4 18905.5\n", "280 2017 Q1 16992.1 16903.2 19057.7\n", "\n", "[281 rows x 5 columns]" ] }, "execution_count": 109, "metadata": {}, "output_type": "execute_result" } ], "source": [ "nipa_quarterly_accounts_df.sort_values(\"Real GDP\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "But wait! The table looks like it's sorted in increasing order. This is because `sort_values` defaults to ordering the column in ascending order. To correct this, add in the extra optional parameter" ] }, { "cell_type": "code", "execution_count": 110, "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", " \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", " \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", " \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", " \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", " \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", " \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", " \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", " \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", " \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", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
YearQuarterReal GDIReal GDPNominal GDP
2802017Q116992.116903.219057.7
2792016Q416882.116851.418905.5
2782016Q316953.016778.118729.1
2772016Q216783.016663.518538.0
2762016Q116776.116571.618325.2
2752015Q416789.816547.618287.2
2742015Q316726.716527.618227.7
2732015Q216700.616460.918093.2
2722015Q116599.616350.017874.7
2712014Q416520.816220.217735.9
2702014Q316327.916139.517622.3
2692014Q216136.115935.817320.9
2672013Q415851.315793.916999.9
2682014Q115912.815757.617031.3
2662013Q315752.015641.316749.3
2652013Q215719.815521.616541.4
2642013Q115642.715491.916475.4
2632012Q415650.615384.316297.3
2622012Q315517.115380.816227.9
2612012Q215522.815362.416121.9
2602012Q115500.415291.015973.9
2592011Q415217.015190.315785.3
2582011Q315093.115021.115587.1
2432007Q414816.614991.814685.3
2572011Q214996.114989.615460.9
2452008Q214832.414963.414813.0
2552010Q414904.914939.015230.2
2422007Q314822.414938.514569.7
2462008Q314767.014891.614843.0
2442008Q114842.214889.514668.4
..................
261953Q32555.72578.9391.7
241953Q12554.32573.4388.5
301954Q32537.12559.4391.6
271953Q42504.12539.8386.5
291954Q22514.52530.7386.7
281954Q12510.12528.0385.9
231952Q42509.52526.4381.2
221952Q32435.02446.1368.1
211952Q22412.62428.5361.4
201952Q12398.32423.5360.2
191951Q42382.72398.1356.6
181951Q32362.02392.8351.8
171951Q22321.32344.5344.5
161951Q12281.02304.5336.4
151950Q42268.92273.4320.3
141950Q32225.92230.4308.5
131950Q22144.42147.6290.7
121950Q12060.12084.6281.2
71948Q42041.62035.3280.7
61948Q32031.52033.2279.5
101949Q32007.92022.8273.3
51948Q22030.22021.9272.9
81949Q12001.52007.5275.4
111949Q41979.62004.7271.0
91949Q21995.92000.8271.7
41948Q11984.41989.5266.2
31947Q41932.01960.7260.3
01947Q11912.51934.5243.1
11947Q21910.91932.3246.3
21947Q31914.01930.3250.1
\n", "

281 rows × 5 columns

\n", "
" ], "text/plain": [ " Year Quarter Real GDI Real GDP Nominal GDP\n", "280 2017 Q1 16992.1 16903.2 19057.7\n", "279 2016 Q4 16882.1 16851.4 18905.5\n", "278 2016 Q3 16953.0 16778.1 18729.1\n", "277 2016 Q2 16783.0 16663.5 18538.0\n", "276 2016 Q1 16776.1 16571.6 18325.2\n", "275 2015 Q4 16789.8 16547.6 18287.2\n", "274 2015 Q3 16726.7 16527.6 18227.7\n", "273 2015 Q2 16700.6 16460.9 18093.2\n", "272 2015 Q1 16599.6 16350.0 17874.7\n", "271 2014 Q4 16520.8 16220.2 17735.9\n", "270 2014 Q3 16327.9 16139.5 17622.3\n", "269 2014 Q2 16136.1 15935.8 17320.9\n", "267 2013 Q4 15851.3 15793.9 16999.9\n", "268 2014 Q1 15912.8 15757.6 17031.3\n", "266 2013 Q3 15752.0 15641.3 16749.3\n", "265 2013 Q2 15719.8 15521.6 16541.4\n", "264 2013 Q1 15642.7 15491.9 16475.4\n", "263 2012 Q4 15650.6 15384.3 16297.3\n", "262 2012 Q3 15517.1 15380.8 16227.9\n", "261 2012 Q2 15522.8 15362.4 16121.9\n", "260 2012 Q1 15500.4 15291.0 15973.9\n", "259 2011 Q4 15217.0 15190.3 15785.3\n", "258 2011 Q3 15093.1 15021.1 15587.1\n", "243 2007 Q4 14816.6 14991.8 14685.3\n", "257 2011 Q2 14996.1 14989.6 15460.9\n", "245 2008 Q2 14832.4 14963.4 14813.0\n", "255 2010 Q4 14904.9 14939.0 15230.2\n", "242 2007 Q3 14822.4 14938.5 14569.7\n", "246 2008 Q3 14767.0 14891.6 14843.0\n", "244 2008 Q1 14842.2 14889.5 14668.4\n", ".. ... ... ... ... ...\n", "26 1953 Q3 2555.7 2578.9 391.7\n", "24 1953 Q1 2554.3 2573.4 388.5\n", "30 1954 Q3 2537.1 2559.4 391.6\n", "27 1953 Q4 2504.1 2539.8 386.5\n", "29 1954 Q2 2514.5 2530.7 386.7\n", "28 1954 Q1 2510.1 2528.0 385.9\n", "23 1952 Q4 2509.5 2526.4 381.2\n", "22 1952 Q3 2435.0 2446.1 368.1\n", "21 1952 Q2 2412.6 2428.5 361.4\n", "20 1952 Q1 2398.3 2423.5 360.2\n", "19 1951 Q4 2382.7 2398.1 356.6\n", "18 1951 Q3 2362.0 2392.8 351.8\n", "17 1951 Q2 2321.3 2344.5 344.5\n", "16 1951 Q1 2281.0 2304.5 336.4\n", "15 1950 Q4 2268.9 2273.4 320.3\n", "14 1950 Q3 2225.9 2230.4 308.5\n", "13 1950 Q2 2144.4 2147.6 290.7\n", "12 1950 Q1 2060.1 2084.6 281.2\n", "7 1948 Q4 2041.6 2035.3 280.7\n", "6 1948 Q3 2031.5 2033.2 279.5\n", "10 1949 Q3 2007.9 2022.8 273.3\n", "5 1948 Q2 2030.2 2021.9 272.9\n", "8 1949 Q1 2001.5 2007.5 275.4\n", "11 1949 Q4 1979.6 2004.7 271.0\n", "9 1949 Q2 1995.9 2000.8 271.7\n", "4 1948 Q1 1984.4 1989.5 266.2\n", "3 1947 Q4 1932.0 1960.7 260.3\n", "0 1947 Q1 1912.5 1934.5 243.1\n", "1 1947 Q2 1910.9 1932.3 246.3\n", "2 1947 Q3 1914.0 1930.3 250.1\n", "\n", "[281 rows x 5 columns]" ] }, "execution_count": 110, "metadata": {}, "output_type": "execute_result" } ], "source": [ "nipa_quarterly_accounts_df.sort_values(\"Real GDP\", ascending=False)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now we can clearly see that the highest real GDP was attained in the first quarter of this year, and had a value of 16903.2" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### 2.5.5. Some Useful Functions for Numeric Data \n", "\n", "Here are a few useful functions when dealing with numeric data columns.\n", "To find the minimum value in a column, call `min()` on a column of the table." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "nipa_quarterly_accounts_df[\"Real GDP\"].min()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "To find the maximum value, call `max()`." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "nipa_quarterly_accounts_df[\"Nominal GDP\"].max()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "And to find the average value of a column, use `mean()`." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "nipa_quarterly_accounts_df[\"Real GDI\"].mean()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " \n", "\n", "## 3.0 Introduction to Data Visualization " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now that you can read in data and manipulate it, you are now ready to learn about how to visualize data. To begin, run the cells below to import the required packages we will be using." ] }, { "cell_type": "code", "execution_count": 111, "metadata": {}, "outputs": [], "source": [ "%matplotlib inline\n", "import matplotlib.pyplot as plt" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We will be using US unemployment data from [FRED](https://fred.stlouisfed.org/) to show what we can do with data. The statement below will put the csv file into a pandas DataFrame." ] }, { "cell_type": "code", "execution_count": 112, "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", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
datetotal_unemployedmore_than_15_weeksnot_in_labor_searched_for_workmulti_jobsleaverslosershousing_price_index
011/1/1016.98696253167085.763.0186.07
112/1/1016.68549260968996.461.2183.27
21/1/1116.28393280068166.560.1181.35
32/1/1116.08175273067416.460.2179.66
43/1/1115.98166243467356.460.3178.84
\n", "
" ], "text/plain": [ " date total_unemployed more_than_15_weeks \\\n", "0 11/1/10 16.9 8696 \n", "1 12/1/10 16.6 8549 \n", "2 1/1/11 16.2 8393 \n", "3 2/1/11 16.0 8175 \n", "4 3/1/11 15.9 8166 \n", "\n", " not_in_labor_searched_for_work multi_jobs leavers losers \\\n", "0 2531 6708 5.7 63.0 \n", "1 2609 6899 6.4 61.2 \n", "2 2800 6816 6.5 60.1 \n", "3 2730 6741 6.4 60.2 \n", "4 2434 6735 6.4 60.3 \n", "\n", " housing_price_index \n", "0 186.07 \n", "1 183.27 \n", "2 181.35 \n", "3 179.66 \n", "4 178.84 " ] }, "execution_count": 112, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import pandas as pd\n", "\n", "unemployment_data = pd.read_csv(\"https://delong.typepad.com/detailed_unemployment.csv\")\n", "unemployment_data.head()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "One of the advantages of pandas is its built-in plotting methods. We can simply call `.plot()` on a dataframe to plot columns against one another. All that we have to do is specify which column to plot on which axis. Something special that pandas does is attempt to automatically parse dates into something that it can understand and order them sequentially.\n", "\n", ">**Note:** `total_unemployed` is a percentage—not a number. Divide it by 100 to get the unemployment rate as a number." ] }, { "cell_type": "code", "execution_count": 113, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "" ] }, "execution_count": 113, "metadata": {}, "output_type": "execute_result" }, { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAEKCAYAAADpfBXhAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3XlclWX+//HXhwMIKAqyuSCCkoorBpJL7pW2atPqlGtm\n1lRW0/armWmbZtpmWqymzb1ybPKrlmXlkqm5oqLivqEhKriAgoIs1++PczRQEDgczoHD5/l48PBw\nn+u+7/c5wof7XPd1X7cYY1BKKeVePFwdQCmllONpcVdKKTekxV0ppdyQFnellHJDWtyVUsoNaXFX\nSik3pMVdKaXckBZ3pZRyQ1rclVLKDXk6c2fBwcEmMjLSmbtUSqlab/369ceMMSGVWcepxT0yMpLE\nxERn7lIppWo9ETlQ2XW0W0YppdyQFnellHJD5RZ3EZksIukiklxs2SwRSbJ9pYhIUvXGVEopVRkV\n6XOfCrwPTD+/wBhz1/nHIvIvIMvhyZSq4/Lz80lNTSU3N9fVUZST+Pj4EB4ejpeXV5W3VW5xN8Ys\nE5HI0p4TEQHuBAZUOYlSqoTU1FT8/f2JjIzE+qum3JkxhuPHj5OamkpUVFSVt1fVPvfewFFjzO4q\nJ1FKlZCbm0tQUJAW9jpCRAgKCnLYJ7WqFvdhwMzLNRCRcSKSKCK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AhU+p59+joVgPDOzihNqyDuuB7vnzYAMo732/3NlW8/tZ2plYR0/k\nY/0Lch9wq+1xHnAU+NHWdh3gW2zdN2ztimz/voj1RN2Si/axHMgAztraDbItb4X1r9oerN0R9SqS\nuYzXsdz2hmzC+gMQD0y9qE0K1hM82bYc7bH+4o0q1qab7bkcrJ8utpb3Oqr6hfVs+3Ggke17h2YH\n7rX9/yYV+4qtYuZWtvd6E9ai/nw15L4W2Gzbx2ZgnIPe787ARts2k4G/VcfPS7E2o3DMaJmLf1ef\ncfD73RPYYnu/twD3OTivM2vLEttrSAY+xzY6ys7X4Yzacv5nfQvWkT7el83kiF+EYjsPBxZUoN29\nwLOO3Ledef+CbZhlOe0WAk1dndcdstfW3LU1e23MXEY+rS2V/NLpB5RSyg3p9ANKKeWGtLgrpZQb\n0uKulFJuSIu7Ukq5IS3uqk4RkRdFpMzL/UVkqG0eD6VqNS3uSpU0FOv4Y6VqNR0KqdyeiDyP9erm\ndKyTi60HsoBxWCdI2wMMB2KB+bbnsrBO1QrwAdaLY84A9xtjdjgzv1L20OKu3JptSt2pWCeT8gQ2\nYL0vwBRjzHFbm78DR40xE0VkKtZ5v7+2PbcYGG+M2S0iVwH/NMYMcP4rUapyPMtvolSt1huYY2xz\nX8vvdw7qaCvqAVhvfPDjxSuKSAOsl9v/zzr9CGCdM16pGk+Lu6qrpgJDjTGbRGQU0K+UNh5Y7ydg\n9+3XlHIVPaGq3N0yYKiI+NpmqLzZttwfOCwiXsA9xdqftj2HMeYUsF9E7gDr7IEi0sV50ZWynxZ3\n5daMMRuAWVhn61uAdWZBgL9ivaHDr0DxE6T/BZ6y3e2mNdbCf5+InJ/ZcoizsitVFXpCVSml3JAe\nuSullBvS4q6UUm5Ii7tSSrkhLe5KKeWGtLgrpZQb0uKulFJuSIu7Ukq5IS3uSinlhv4/hKK0XWIW\nlq8AAAAASUVORK5CYII=\n", "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "unemployment_data.plot(x='date', y='total_unemployed')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The base package for most plotting in Python is `matplotlib`. Below we will look at how to plot with it. First we will extract the columns that we are interested in, then plot them in a scatter plot. Note that `plt` is the common convention for `matplotlib.pyplot`." ] }, { "cell_type": "code", "execution_count": 114, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "" ] }, "execution_count": 114, "metadata": {}, "output_type": "execute_result" }, { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAY8AAAEKCAYAAADq59mMAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3Xu4nGV57/HvjxAwSjFiooVF0tAKVM7IktIGqqIFtnpJ\nioq0Crh1G5GooGyUUGt1t5Qoii1YUAo2oHhAOUhFjEhQUUviAgIhRCQICgsEVBDQCDnc+4/3WTCZ\nrJl5Z615Z9535ve5rrmYeeZ0r7XC3POc7kcRgZmZWTu26HUAZmZWPU4eZmbWNicPMzNrm5OHmZm1\nzcnDzMza5uRhZmZtc/IwM7O2OXmYmVnbnDzMzKxtW/Y6gKLMmDEj5syZ0+swzMwqY8aMGSxZsmRJ\nRBzW6rF9mzzmzJnDyMhIr8MwM6sUSTPyPM7DVmZm1jYnDzMza5uTh5mZtc3Jw8zM2ubkYWZmbevb\n1VZm1t+uuHmUM5bcwf2PrmWH6dM4+dBdmbfvUK/DGhiF9TwkzZJ0naTbJa2SdEJq30fSDZJWSBqR\ntH/NcxZKWiPpDkmH1rTvJ2lluu8sSSoqbjMrvytuHmXhZSsZfXQtAYw+upaFl63kiptHex3awChy\n2Go9cFJE7AYcACyQtBvwceCjEbEP8OF0m3TfUcDuwGHAOZKmpNc6F3gHsHO6tNzAYmb964wld7B2\n3YZN2tau28AZS+7oUUSbu+LmUeYuWspOp1zF3EVL+y6xFZY8IuKBiLgpXX8cWA0MAQFsmx72XOD+\ndP1w4MsR8WRE3A2sAfaXtD2wbUTcENmB6xcB84qK28zK7/5H17bV3m2D0D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QSWH\nAAAAAElFTkSuQmCC\n", "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "total_unemployed = unemployment_data['total_unemployed']\n", "not_labor = unemployment_data['not_in_labor_searched_for_work']\n", "\n", "#Plot the data by inputting the x and y axis\n", "plt.scatter(total_unemployed, not_labor)\n", "\n", "# we can then go on to customize the plot with labels\n", "plt.xlabel(\"Percent Unemployed\")\n", "plt.ylabel(\"Total Not In Labor, Searched for Work\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Though matplotlib is sometimes considered an \"ugly\" plotting tool, it is powerful. It is highly customizable and is the foundation for most Python plotting libraries. Check out the [documentation](https://matplotlib.org/api/pyplot_summary.html) to get a sense of all of the things you can do with it, which extend far beyond scatter and line plots. An arguably more attractive package is [seaborn](https://seaborn.pydata.org/), which we will go over in future notebooks.\n", "\n", " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ ">**Understanding Check 3.1**: Try plotting the total percent of people unemployed vs those unemployed for more than 15 weeks." ] }, { "cell_type": "code", "execution_count": 115, "metadata": {}, "outputs": [ { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAY8AAAEKCAYAAADq59mMAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3XucXFWZ7//PN00DHSQ0SMyEBk4CIh4wQDSDERAVR4KO\nh0SUi4OKyoFROII6EwnqbxRHh8wvXmaUow4zAwEv0YAa7iJXcRgDJiQxXAeGAKHlEpGbEGLTec4f\ne1VSXV2XXd1VXdXd3/frVa/ae9Xeu54qQq3e6/IsRQRmZmb1mNDqAMzMbPRx5WFmZnVz5WFmZnVz\n5WFmZnVz5WFmZnVz5WFmZnVz5WFmZnVz5WFmZnVz5WFmZnXbptYBknYANkbEZkmvAV4LXBMRfU2P\nbhh23XXXmDZtWqvDMDMbNXbddVeuvfbaayPiqFrH1qw8gFuAN0vaGfgF8BvgeODE4YXZXNOmTWPF\nihWtDsPMbFSRt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sOy84VtIEZf05ewGllcS1ZAslKV13\nZpl4Hgb2S99RN/D2HJ8hz3VrOT6dexjwbPo+i1X73BeTZcC+ELasxljp+7u15Do2Alx52AAR8RRZ\nk9GdkhYBPyNr918D3EjW5/B4KutX1ln9KeDbwEmS1pA1rdS6QwD4DVn7+z3AOuBnEbGBrF18iaTf\nkjVZlTbVFHwQOCMd95/An0XEL8h+dH4taS1wKWUqhhKLge+qTIc5WYr8Rek9DiLr96jlBbKK8U7g\niKJzTgROTt/RXWTp2QE+AXwkvccHgTOLrvUIWWV9DVnfQukd3d+TNRn+VtJdaX+AiFhP1sdzZ3pe\nVXpMGTWvm8NLklYB3yXLPluq2uf+AbAzAxcvqvT9nQmcnv579wwhThsCZ9W1lkhNEn8bEYNGEI12\nkv4YEa9owHUWk3V0Xzr8qEaWpJvJ/vuuGOL57wPmRsQHGxqYNYz7PMysrUj6FvBO4F2tjsUq852H\nmZnVzX0eZmZWN1ceZmZWN1ceZmZWN1ceZmZWN1ceZmZWN1ceZmZWt/8Hzu/SneVbTbwAAAAASUVO\nRK5CYII=\n", "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "total_unemployed = unemployment_data['total_unemployed']\n", "unemp_15_weeks = unemployment_data['more_than_15_weeks']\n", "\n", "plt.scatter(total_unemployed, unemp_15_weeks)\n", "plt.xlabel('total percent of people unemployed')\n", "plt.ylabel('people unemployed for more than 15 weeks')\n", "\n", "# note: plt.show() is the equivalent of print, but for graphs\n", "plt.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Some materials in this notebook were taken from [Data 8](http://data8.org/), [CS 61A](http://cs61a.org/), and [DS Modules](http://data.berkeley.edu/education/modules) lessons." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "----\n", "\n", " \n", "\n", "## Introduction: Python \n", "\n", "\n", "\n", "### Catch Our Breath—Further Notes:\n", "\n", "
\n", "\n", "----\n", "\n", "* weblog support: \n", "* nbViewer: \n", "* datahub: \n", "\n", "----" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## The Fine Chancery Hand of the Twenty-First Century \n", "\n", "### David Guarino, UCB '07, on LinkedIn \n", "\n", "\"Https" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "\n", "\n", "\n", "" ] } ], "metadata": { "anaconda-cloud": {}, "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.6.1" } }, "nbformat": 4, "nbformat_minor": 4 }