{
"metadata": {
"name": "",
"signature": "sha256:0b13dfe9b27fc566db40aa1b3c9da6f07a69453573a5a55ba3f47b8be60cc504"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Test Script\n",
"\n",
"- **Author:** [Chris Albon](http://www.chrisalbon.com/), [@ChrisAlbon](https://twitter.com/chrisalbon)\n",
"- **Date:** -\n",
"- **Repo:** [Python 3 code snippets for data science](https://github.com/chrisalbon/code_py)\n",
"- **Note:**\n",
"\n",
"Checks the right environment is being used and one of the data science modules is installed"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Import the modules"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"import sys\n",
"import IPython"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 9
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Print the path to the Python environment."
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"print(sys.executable)\n",
"print(sys.version)"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"/Users/chrisralbon/anaconda/envs/py3k/bin/python\n",
"3.3.5 |Anaconda 2.1.0 (x86_64)| (default, Sep 2 2014, 13:57:31) \n",
"[GCC 4.2.1 (Apple Inc. build 5577)]\n"
]
}
],
"prompt_number": 10
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Check which version of iPython is being used."
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"IPython.__version__"
],
"language": "python",
"metadata": {},
"outputs": [
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 11,
"text": [
"'2.2.0'"
]
}
],
"prompt_number": 11
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Run a quick test to see if numpy module is installed."
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"import numpy as np\n",
"arr = np.arange(100)\n",
"arr"
],
"language": "python",
"metadata": {},
"outputs": [
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 12,
"text": [
"array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,\n",
" 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,\n",
" 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50,\n",
" 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67,\n",
" 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,\n",
" 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99])"
]
}
],
"prompt_number": 12
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Run a quick test to see if pandas module is installed."
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"import pandas as pd"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 13
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"df = pd.DataFrame(np.random.randn(8, 3), \n",
" index=pd.date_range('1/1/2000', periods=8), \n",
" columns=['A', 'B', 'C'])\n",
"df"
],
"language": "python",
"metadata": {},
"outputs": [
{
"html": [
"
\n",
"
\n",
" \n",
" \n",
" | \n",
" A | \n",
" B | \n",
" C | \n",
"
\n",
" \n",
" \n",
" \n",
" 2000-01-01 | \n",
" 0.941488 | \n",
" 1.325088 | \n",
" -2.251415 | \n",
"
\n",
" \n",
" 2000-01-02 | \n",
" -0.031463 | \n",
" -0.342263 | \n",
" -0.255721 | \n",
"
\n",
" \n",
" 2000-01-03 | \n",
" 0.180192 | \n",
" -0.236305 | \n",
" 0.135585 | \n",
"
\n",
" \n",
" 2000-01-04 | \n",
" -2.088548 | \n",
" 1.204635 | \n",
" 0.916760 | \n",
"
\n",
" \n",
" 2000-01-05 | \n",
" -0.461350 | \n",
" -1.350354 | \n",
" -0.261618 | \n",
"
\n",
" \n",
" 2000-01-06 | \n",
" -0.130376 | \n",
" 1.732998 | \n",
" 0.301640 | \n",
"
\n",
" \n",
" 2000-01-07 | \n",
" -0.781489 | \n",
" 0.738901 | \n",
" -0.289822 | \n",
"
\n",
" \n",
" 2000-01-08 | \n",
" 0.295216 | \n",
" -0.610543 | \n",
" -1.941927 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"metadata": {},
"output_type": "pyout",
"prompt_number": 14,
"text": [
" A B C\n",
"2000-01-01 0.941488 1.325088 -2.251415\n",
"2000-01-02 -0.031463 -0.342263 -0.255721\n",
"2000-01-03 0.180192 -0.236305 0.135585\n",
"2000-01-04 -2.088548 1.204635 0.916760\n",
"2000-01-05 -0.461350 -1.350354 -0.261618\n",
"2000-01-06 -0.130376 1.732998 0.301640\n",
"2000-01-07 -0.781489 0.738901 -0.289822\n",
"2000-01-08 0.295216 -0.610543 -1.941927"
]
}
],
"prompt_number": 14
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### View the first 4 rows."
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"df[0:4]"
],
"language": "python",
"metadata": {},
"outputs": [
{
"html": [
"\n",
"
\n",
" \n",
" \n",
" | \n",
" A | \n",
" B | \n",
" C | \n",
"
\n",
" \n",
" \n",
" \n",
" 2000-01-01 | \n",
" 0.941488 | \n",
" 1.325088 | \n",
" -2.251415 | \n",
"
\n",
" \n",
" 2000-01-02 | \n",
" -0.031463 | \n",
" -0.342263 | \n",
" -0.255721 | \n",
"
\n",
" \n",
" 2000-01-03 | \n",
" 0.180192 | \n",
" -0.236305 | \n",
" 0.135585 | \n",
"
\n",
" \n",
" 2000-01-04 | \n",
" -2.088548 | \n",
" 1.204635 | \n",
" 0.916760 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"metadata": {},
"output_type": "pyout",
"prompt_number": 15,
"text": [
" A B C\n",
"2000-01-01 0.941488 1.325088 -2.251415\n",
"2000-01-02 -0.031463 -0.342263 -0.255721\n",
"2000-01-03 0.180192 -0.236305 0.135585\n",
"2000-01-04 -2.088548 1.204635 0.916760"
]
}
],
"prompt_number": 15
}
],
"metadata": {}
}
]
}