{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "This short guide will help you get started with the anaconda python distribution on your PC or MAC. If you happen to run linux, please contact Professor Hicks directly.\n", "\n", "# Installing Python\n", "\n", "Both the PC and MAC installers can be downloaded at [http://continuum.io/downloads](http://continuum.io/downloads).\n", "\n", "Take care that you are downloading Python 3.x (which is the default) for your platform. The 64bit version (also the default) is what you want in 99% of all cases. " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Once you have downloaded the installer, do the following:\n", "\n", "1. Navigate to your your browser's download folder \n", "2. Open the python executable (e.g. Anaconda3-4.3.1-Windows-x86_64.exe [PC] or Anaconda3-4.3.1-MacOSX-x86_64.pkg [MAC])\n", "3. Click through the install screens and choose to install \"Just Me\" and don't change the default install location. Leave any \"Advanced Options\" at their default values. \n", "\n", "\n", "# Using Python\n", "\n", "Now that python is installed and updated, we can use it. There are several ways to run python code, and I will show you a method allowing you to use your web browser as a \"front-end\" for python.\n", "\n", "We will be using the Ipython Notebook (now called Jupyter). The easiest way to open it is to locate and use the Anaconda Launcher. Hopefully, the install process will put this in your `Program Files` (PC) or `Applications` (Mac). If you see a new icon labeled Anaconda Launcher, click it and choose ipython notebook. Sometimes, the install process doesn't create the Anaconda icon. In this case, it is possible to locate it in the Anaconda folder in your local home directory.\n", "\n", "In case you can't find the Anaconda icon, you can also launch it from the terminal or command prompt window, type ``ipython notebook``. \n", "\n", "If you have made it this far, your web browser should pop up and you should see a window like this (note: the actual filenames and folders you will see will reflect the actual information you have on your computer):\n", "![](../site_pics/ipython_main.png)\n", "\n", "This listing allows you to see existing and running Ipython Notebooks. You won't have any, so let's create one. You can navigate to a folder of your choosing and create a new notebook by clicking on `New` and then `Python 3` [note the screenshot below is old and show `Python 2`] as shown below:\n", "\n", "![](../site_pics/ipython_main2.png)" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true }, "source": [ "## Testing the installation\n", "\n", "Having created a new notebook, you should see a window that looks like this:\n", "![](../site_pics/notebook1.png)\n", "\n", "You can re-name your new untitled notebook by clicking on ``Untitled`` and changing the name:\n", "![](../site_pics/notebook2.png)" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true }, "source": [ "Ipython Notebooks have execution blocks where you can enter and execute python code. These blocks look like this:\n", "![](../site_pics/execute.png)\n", "\n", "Copy and paste the following code into the first (and only at this point) execution block:\n", "```\n", "%matplotlib inline\n", "import pandas as pd\n", "import numpy as np\n", "import matplotlib pyplot as plt\n", "import statsmodels.formula.api as sm\n", "import sympy as sympy\n", "```\n", "\n", "You should see output like this after pressing the `shift enter` keys at the same time to execute the code:" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "%matplotlib inline\n", "import pandas as pd\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "import statsmodels.formula.api as sm\n", "import sympy as sympy" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true }, "source": [ "Next, we will make sure things are working. Paste this code into the next execution cell and press ``shift enter``:" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | time | \n", "price | \n", "
---|---|---|
count | \n", "100.000000 | \n", "100.000000 | \n", "
mean | \n", "50.500000 | \n", "9.866077 | \n", "
std | \n", "29.011492 | \n", "2.946530 | \n", "
min | \n", "1.000000 | \n", "2.643740 | \n", "
25% | \n", "25.750000 | \n", "8.113189 | \n", "
50% | \n", "50.500000 | \n", "9.724360 | \n", "
75% | \n", "75.250000 | \n", "11.569507 | \n", "
max | \n", "100.000000 | \n", "18.147543 | \n", "