{ "cells": [ { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "# Breakout 2 Solutions\n", "Note, you can find this notebook on Github here:\n", "\n", "http://bit.ly/advanced_data_structures_2016\n", "\n", "# Sorting airline data" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "### First, copy over the airport and flight information\n", "You can find the data in [airline.py](https://raw.github.com/profjsb/python-bootcamp/master/DataFiles_and_Notebooks/02_AdvancedDataStructures/airline.py)" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# Note that we could do this with the following command too:\n", "# %load https://raw.githubusercontent.com/profjsb/python-bootcamp/master/DataFiles_and_Notebooks/02_AdvancedDataStructures/airline.py" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": true, "slideshow": { "slide_type": "fragment" } }, "outputs": [], "source": [ "airports = {\"DCA\": \"Washington, D.C.\", \"IAD\": \"Dulles\", \"LHR\": \"London-Heathrow\", \\\n", " \"SVO\": \"Moscow\", \"CDA\": \"Chicago-Midway\", \"SBA\": \"Santa Barbara\", \"LAX\": \"Los Angeles\",\\\n", " \"JFK\": \"New York City\", \"MIA\": \"Miami\", \"AUM\": \"Austin, Minnesota\"}\n", "\n", "# airline, number, heading to, gate, time (decimal hours) \n", "flights = [(\"Southwest\",145,\"DCA\",1,6.00),(\"United\",31,\"IAD\",1,7.1),(\"United\",302,\"LHR\",5,6.5),\\\n", " (\"Aeroflot\",34,\"SVO\",5,9.00),(\"Southwest\",146,\"CDA\",1,9.60), (\"United\",46,\"LAX\",5,6.5),\\\n", " (\"Southwest\",23,\"SBA\",6,12.5),(\"United\",2,\"LAX\",10,12.5),(\"Southwest\",59,\"LAX\",11,14.5),\\\n", " (\"American\", 1,\"JFK\",12,11.3),(\"USAirways\", 8,\"MIA\",20,13.1),(\"United\",2032,\"MIA\",21,15.1),\\\n", " (\"SpamAir\",1,\"AUM\",42,14.4)]" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "{'AUM': 'Austin, Minnesota',\n", " 'CDA': 'Chicago-Midway',\n", " 'DCA': 'Washington, D.C.',\n", " 'IAD': 'Dulles',\n", " 'JFK': 'New York City',\n", " 'LAX': 'Los Angeles',\n", " 'LHR': 'London-Heathrow',\n", " 'MIA': 'Miami',\n", " 'SBA': 'Santa Barbara',\n", " 'SVO': 'Moscow'}" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# airports is a dictionary that maps airport code to airport city\n", "airports" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "[('Southwest', 145, 'DCA', 1, 6.0),\n", " ('United', 31, 'IAD', 1, 7.1),\n", " ('United', 302, 'LHR', 5, 6.5)]" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# flights is a collection of tuples, each one specifying one flight\n", "# Columns are: airline, number, heading to, gate, time (decimal hours)\n", "flights[:3]" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "# Sorting by Airline\n", "Python lists have a `.sort` function that automatically sorts the contents that are inside. If the list contains collections (like tuples), then it will sort based on the first item in each collection.\n", "\n", "Since airline is the first element of our `flights` tuples, we can sort the flight information by airline by running a simple sort on the list.\n" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "collapsed": false, "slideshow": { "slide_type": "fragment" } }, "outputs": [], "source": [ "# Sort the list of flights.\n", "flights.sort() " ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "fragment" } }, "source": [ "Note that if there are multiple items in `flights` that have the same first item, it will then go on to the next item.\n", "\n", "Moreover, note that calling the `.sort` method of `flights` didn't return anything, it modified the contents of `flights` in place." ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "collapsed": false, "slideshow": { "slide_type": "fragment" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "('Aeroflot', 34, 'SVO', 5, 9.0)\n", "('American', 1, 'JFK', 12, 11.3)\n", "('Southwest', 23, 'SBA', 6, 12.5)\n", "('Southwest', 59, 'LAX', 11, 14.5)\n", "('Southwest', 145, 'DCA', 1, 6.0)\n", "('Southwest', 146, 'CDA', 1, 9.6)\n", "('SpamAir', 1, 'AUM', 42, 14.4)\n", "('USAirways', 8, 'MIA', 20, 13.1)\n", "('United', 2, 'LAX', 10, 12.5)\n", "('United', 31, 'IAD', 1, 7.1)\n", "('United', 46, 'LAX', 5, 6.5)\n", "('United', 302, 'LHR', 5, 6.5)\n", "('United', 2032, 'MIA', 21, 15.1)\n" ] } ], "source": [ "for flight in flights:\n", " print(flight)" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "# Printing the list\n", "Now we want to print out the sorted list in a nicer format. This is tricky, because different names have different lengths, so the challenge is making sure that each category begins printing at the same point.\n", "\n", "First, we'll figure out how to print our header information nicely" ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Flight \tDestination\t\tGate\tTime\n", "----------------------------------------------------\n" ] } ], "source": [ "# Print out the header. the \\t character prints a tab.\n", "header = \"Flight \\tDestination\\t\\tGate\\tTime\"\n", "print(header)\n", "\n", "# `expandtabs` will convert the `\\t` character to spaces so we know the length\n", "print(\"-\" * len(header.expandtabs()))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "By using tabs (`\\t`), we can space out the categories. We should use more tabs if the category will have longer values.\n", "\n", "Next, we'll print our data underneath this header. First we'll have a quick aside on **inserting variables into a string**:" ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "hi\n" ] } ], "source": [ "# First, note that we can insert variables into strings\n", "# We accomplish this with the characters `{}` + the `format` method\n", "print('{}'.format('hi'))" ] }, { "cell_type": "code", "execution_count": 9, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "3 blind mice\n" ] } ], "source": [ "# This will auto-convert items like ints or floats to a string\n", "print('{} blind mice'.format(3))" ] }, { "cell_type": "code", "execution_count": 10, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "3 shall be the number thou shalt count, and the number of the counting shall be 3\n" ] } ], "source": [ "# You can also specify multiple variables to insert\n", "print('{} shall be the number thou shalt count, and'\n", " ' the number of the counting shall be {}'.format(3, 3))" ] }, { "cell_type": "code", "execution_count": 11, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Wait, there are 2 ways to do this, that is crazy!!!\n", "Wow a 3rd way, truly python is 2 cool 4 school...\n" ] } ], "source": [ "# We can also use the `%` symbol like so:\n", "number, word = 2, 'crazy'\n", "print('Wait, there are %s ways to do this, that is %s!!!' % (number, word))\n", "\n", "# And we can also directly convert variables to string format, then use +\n", "print(\"Wow a \" + str(3) + \"rd way, truly python is \" + str(2) + \" cool \" + str(4) + \" school...\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now, on to printing our data. We'll just print whatever is in the dataset:\n", "\n", "*Note that when printing, we lookup the destination name by the airport code key in the airports dictionary.*" ] }, { "cell_type": "code", "execution_count": 12, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Flight \tDestination\t\tGate\tTime\n", "----------------------------------------------------\n", "Aeroflot 34 \t Moscow \t 5 \t 9.0\n", "American 1 \t New York City \t 12 \t 11.3\n", "Southwest 23 \t Santa Barbara \t 6 \t 12.5\n", "Southwest 59 \t Los Angeles \t 11 \t 14.5\n", "Southwest 145 \t Washington, D.C. \t 1 \t 6.0\n", "Southwest 146 \t Chicago-Midway \t 1 \t 9.6\n", "SpamAir 1 \t Austin, Minnesota \t 42 \t 14.4\n", "USAirways 8 \t Miami \t 20 \t 13.1\n", "United 2 \t Los Angeles \t 10 \t 12.5\n", "United 31 \t Dulles \t 1 \t 7.1\n", "United 46 \t Los Angeles \t 5 \t 6.5\n", "United 302 \t London-Heathrow \t 5 \t 6.5\n", "United 2032 \t Miami \t 21 \t 15.1\n" ] } ], "source": [ "# Print the header\n", "print(header)\n", "print(\"-\" * len(header.expandtabs()))\n", "\n", "# Now print the flight information\n", "for flight in flights:\n", " dest = airports[flight[2]]\n", " # Print the nicely formatted string. Don't forget to convert int and float types to strings using str()\n", " print('{} {} \\t {} \\t {} \\t {}'.format(\n", " flight[0], flight[1], dest, flight[3], flight[4]))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Hmmm, it's close, but there are problems related to differing lenghts of the flight information. In particular it seems like the `Destination` column is giving us problems.\n", "\n", "To get around this, we can define a custom amount of whitespace for this column, depending on the length of the string (rather than using tabs)." ] }, { "cell_type": "code", "execution_count": 13, "metadata": { "collapsed": false, "slideshow": { "slide_type": "fragment" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Flight \tDestination\t\tGate\tTime\n", "----------------------------------------------------\n", "Aeroflot 34 \t Moscow \t 5 \t 9.0\n", "American 1 \t New York City \t 12 \t 11.3\n", "Southwest 23 \t Santa Barbara \t 6 \t 12.5\n", "Southwest 59 \t Los Angeles \t 11 \t 14.5\n", "Southwest 145 \t Washington, D.C. \t 1 \t 6.0\n", "Southwest 146 \t Chicago-Midway \t 1 \t 9.6\n", "SpamAir 1 \t Austin, Minnesota \t 42 \t 14.4\n", "USAirways 8 \t Miami \t 20 \t 13.1\n", "United 2 \t Los Angeles \t 10 \t 12.5\n", "United 31 \t Dulles \t 1 \t 7.1\n", "United 46 \t Los Angeles \t 5 \t 6.5\n", "United 302 \t London-Heathrow \t 5 \t 6.5\n", "United 2032 \t Miami \t 21 \t 15.1\n" ] } ], "source": [ "# Print the header\n", "print(header)\n", "print(\"-\" * len(header.expandtabs()))\n", "\n", "# Now print the flight information\n", "destination_column_length = 20\n", "for flight in flights:\n", " dest = airports[flight[2]]\n", " \n", " # add the appropriate amount of whitespace after the Destination string\n", " dest += \" \" * (destination_column_length - len(dest))\n", " \n", " print('{} {} \\t {} \\t {} \\t {}'.format(\n", " flight[0], flight[1], dest, flight[3], flight[4]))\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Sorting by Departure Time\n", "We'll do this three ways (there are often many ways to solve a problem in coding)...you can decide which one makes more sense to you." ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "## Sorting the information by time manually\n", "Rather than using python's sorting functionality, we also could have done this ourselves manually. In this case, it requires about the same amount of code but has some tricky logic. I won't go into details on how to do this, but you can find the solution below...\n", "\n", "First, we create a new list, time_ordered_flights, which initially just contains the first element of the list flights." ] }, { "cell_type": "code", "execution_count": 14, "metadata": { "collapsed": false, "slideshow": { "slide_type": "fragment" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[('Aeroflot', 34, 'SVO', 5, 9.0)]\n" ] } ], "source": [ "# Create a new list, time_ordered, which initially just contains the first element of the list flights\n", "time_ordered_flights = [flights[0]]\n", "print(time_ordered_flights)" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "fragment" } }, "source": [ "We then loop through the remaining flights and insert it into the proper position in time_ordered_flights by comparing the time element in each flight tuple (at the fifth index position).\n", "\n", "We determine where the current flight belongs by manually comparing the times of the flights already added to time_ordered_flights. (This is really trivial with lambda functions, which you'll learn later.)" ] }, { "cell_type": "code", "execution_count": 15, "metadata": { "collapsed": true, "slideshow": { "slide_type": "fragment" } }, "outputs": [], "source": [ "# Iterate through each of the remaining elements in flights to see where it should go in the sorted list\n", "ix_time = 4\n", "for flight in flights[1:]:\n", " this_time = flight[ix_time]\n", " first_time = time_ordered_flights[0][ix_time]\n", " last_time = time_ordered_flights[-1][ix_time]\n", " # Does it belong in the beginning?\n", " # Is current flight's time less than the time in the first list element?\n", " if this_time < first_time:\n", " # insert the flight tuple at position 0 in the list \n", " time_ordered_flights.insert(0,flight)\n", " continue\n", " ## ... or the end?\n", " # is current flight's time greater than the time in the last list element?\n", " if this_time > last_time:\n", " # append the flight tuple to the end of the list \n", " time_ordered_flights.append(flight)\n", " continue\n", " ## Or is it in the middle?\n", " ## Loop through each element and see if the cur flight is b/w two others\n", " ## note that range(N) returns a list [0, 1, ... , N-1] \n", " for ii in range(len(time_ordered_flights) - 1): \n", " if (this_time >= time_ordered_flights[ii][ix_time] and \n", " this_time <= time_ordered_flights[ii + 1][ix_time]):\n", " # insert the flight tuple at position i + 1 in the list\n", " time_ordered_flights.insert(ii + 1, flight) \n", " break" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "The printing procedure is the same as before." ] }, { "cell_type": "code", "execution_count": 16, "metadata": { "collapsed": false, "slideshow": { "slide_type": "fragment" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Flight \tDestination\t\tGate\tTime\n", "-----------------------------------------------------\n", "Southwest 145 \t Washington, D.C. \t 1 \t 6.0\n", "United 302 \t London-Heathrow \t 5 \t 6.5\n", "United 46 \t Los Angeles \t 5 \t 6.5\n", "United 31 \t Dulles \t 1 \t 7.1\n", "Aeroflot 34 \t Moscow \t 5 \t 9.0\n", "Southwest 146 \t Chicago-Midway \t 1 \t 9.6\n", "American 1 \t New York City \t 12 \t 11.3\n", "United 2 \t Los Angeles \t 10 \t 12.5\n", "Southwest 23 \t Santa Barbara \t 6 \t 12.5\n", "USAirways 8 \t Miami \t 20 \t 13.1\n", "SpamAir 1 \t Austin, Minnesota \t 42 \t 14.4\n", "Southwest 59 \t Los Angeles \t 11 \t 14.5\n", "United 2032 \t Miami \t 21 \t 15.1\n" ] } ], "source": [ "print(\"Flight \\tDestination\\t\\tGate\\tTime\")\n", "print(\"-\"*53)\n", "for flight in time_ordered_flights:\n", " dest = airports[flight[2]]\n", " dest += \" \"*(20 - len(dest))\n", " print('{} {} \\t {} \\t {} \\t {}'.format(\n", " flight[0], flight[1], dest, flight[3], flight[4]))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## By re-ordering our flight information + using `sort`\n", "If we want to use the list's `sort` method, we can take advantage of the fact that it operates on the first item of each list by re-ordering the iterms of our flight information." ] }, { "cell_type": "code", "execution_count": 17, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "[[9.0, 34, 'SVO', 5, 'Aeroflot'],\n", " [11.3, 1, 'JFK', 12, 'American'],\n", " [12.5, 23, 'SBA', 6, 'Southwest'],\n", " [14.5, 59, 'LAX', 11, 'Southwest'],\n", " [6.0, 145, 'DCA', 1, 'Southwest']]" ] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# We'll swap flight number and airline\n", "flights_swap = []\n", "for flight in flights:\n", " this_flight = []\n", " for index in [4, 1, 2, 3, 0]:\n", " this_flight.append(flight[index])\n", " flights_swap.append(this_flight)\n", "flights_swap[:5]" ] }, { "cell_type": "code", "execution_count": 18, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# Now, we'll sort this list\n", "flights_swap.sort()\n", "\n", "# And finally we will swap back\n", "flights_sort = []\n", "for flight in flights_swap:\n", " this_flight = []\n", " for index in [4, 1, 2, 3, 0]:\n", " this_flight.append(flight[index])\n", " flights_sort.append(this_flight)" ] }, { "cell_type": "code", "execution_count": 19, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Flight \tDestination\t\tGate\tTime\n", "-----------------------------------------------------\n", "Southwest 145 \t Washington, D.C. \t 1 \t 6.0\n", "United 46 \t Los Angeles \t 5 \t 6.5\n", "United 302 \t London-Heathrow \t 5 \t 6.5\n", "United 31 \t Dulles \t 1 \t 7.1\n", "Aeroflot 34 \t Moscow \t 5 \t 9.0\n", "Southwest 146 \t Chicago-Midway \t 1 \t 9.6\n", "American 1 \t New York City \t 12 \t 11.3\n", "United 2 \t Los Angeles \t 10 \t 12.5\n", "Southwest 23 \t Santa Barbara \t 6 \t 12.5\n", "USAirways 8 \t Miami \t 20 \t 13.1\n", "SpamAir 1 \t Austin, Minnesota \t 42 \t 14.4\n", "Southwest 59 \t Los Angeles \t 11 \t 14.5\n", "United 2032 \t Miami \t 21 \t 15.1\n" ] } ], "source": [ "# Print the header\n", "print(\"Flight \\tDestination\\t\\tGate\\tTime\")\n", "print(\"-\"*53) #53 instances of the \"-\" character\n", "\n", "# Now print the flight information\n", "destination_column_length = 20\n", "for flight in flights_sort:\n", " dest = airports[flight[2]]\n", " \n", " # add the appropriate amount of whitespace after the Destination string\n", " dest += \" \" * (destination_column_length - len(dest))\n", " \n", " print('{} {} \\t {} \\t {} \\t {}'.format(\n", " flight[0], flight[1], dest, flight[3], flight[4]))" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "## By using a special function to sort in one line\n", "To use even less code, we can use another python function called `operator.itemgetter()` as the key in sort. This will sort the object by the fifth element (time), similar to our first solution.\n", "\n", "This brings up a general tip in python: often there are simpler ways to do something if you look for modules / classes / functions that other people have already written. This often saves lines of code, makes your code more readable, and is less prone to bugs." ] }, { "cell_type": "code", "execution_count": 20, "metadata": { "collapsed": false, "slideshow": { "slide_type": "fragment" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Flight \tDestination\t\tGate\tTime\n", "-----------------------------------------------------\n", "Southwest 145 \t Washington, D.C. \t 1 \t 6.0\n", "United 46 \t Los Angeles \t 5 \t 6.5\n", "United 302 \t London-Heathrow \t 5 \t 6.5\n", "United 31 \t Dulles \t 1 \t 7.1\n", "Aeroflot 34 \t Moscow \t 5 \t 9.0\n", "Southwest 146 \t Chicago-Midway \t 1 \t 9.6\n", "American 1 \t New York City \t 12 \t 11.3\n", "Southwest 23 \t Santa Barbara \t 6 \t 12.5\n", "United 2 \t Los Angeles \t 10 \t 12.5\n", "USAirways 8 \t Miami \t 20 \t 13.1\n", "SpamAir 1 \t Austin, Minnesota \t 42 \t 14.4\n", "Southwest 59 \t Los Angeles \t 11 \t 14.5\n", "United 2032 \t Miami \t 21 \t 15.1\n" ] } ], "source": [ "import operator\n", "\n", "# Sort flights using the fifth item\n", "flights.sort(key=operator.itemgetter(4))\n", "\n", "# Now print\n", "print(\"Flight \\tDestination\\t\\tGate\\tTime\")\n", "print(\"-\"*53)\n", "for flight in flights:\n", " dest = airports[flight[2]]\n", " dest += \" \"*(20 - len(dest))\n", " print('{} {} \\t {} \\t {} \\t {}'.format(\n", " flight[0], flight[1], dest, flight[3], flight[4]))" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "\n", "# Appendix\n", "## Alternate printing solution\n", "For the sake of completeness, here's another way that we could have accomplished the same printing that we performed above. Instead of using tab characters (`\\t`), we'll using some python string syntax to define how large we want each section of the string to be.\n", "\n", "Define how many spaces you want each string to occupy. Add enough trailing spaces to each element to fill this number. We'll go over string formatting more tomorrow. " ] }, { "cell_type": "code", "execution_count": 21, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Flight Destination Gate Time \n", "-----------------------------------------------------\n", "Southwest 145 Washington, D.C. 1 6.00\n", "United 46 Los Angeles 5 6.00\n", "United 302 London-Heathrow 5 6.00\n", "United 31 Dulles 1 7.00\n", "Aeroflot 34 Moscow 5 9.00\n", "Southwest 146 Chicago-Midway 1 9.00\n", "American 1 New York City 12 11.00\n", "Southwest 23 Santa Barbara 6 12.00\n", "United 2 Los Angeles 10 12.00\n", "USAirways 8 Miami 20 13.00\n", "SpamAir 1 Austin, Minnesota 42 14.00\n", "Southwest 59 Los Angeles 11 14.00\n", "United 2032 Miami 21 15.00\n" ] } ], "source": [ "print(\"%.20s %.20s %.6s %.5s\" % (\"Flight\" + 20*' ', \"Destination\" + 20*' ',\n", " \"Gate\" + 20*' ', \"Time\" + 20*' '))\n", "print(\"-\"*53)\n", "for flight in flights:\n", " print(\"%.20s %.20s %.6s %5.2f\" % (flight[0] + ' ' + str(flight[1]) + 20*' ', \n", " airports[flight[2]]+20*' ',\n", " str(flight[3])+20*' ',\n", " int(flight[4])))" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [] } ], "metadata": { "hide_input": false, "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.4.4" } }, "nbformat": 4, "nbformat_minor": 0 }