Created
February 7, 2013 12:50
-
-
Save RutgerK/4730709 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"metadata": { | |
"name": "pandas_multi2" | |
}, | |
"nbformat": 3, | |
"nbformat_minor": 0, | |
"worksheets": [ | |
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": "import StringIO\nimport pandas as pd\n\nprint pd.__version__", | |
"language": "python", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": "0.10.0\n" | |
} | |
], | |
"prompt_number": 1 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": "incsv = StringIO.StringIO(\"\"\"col1,col2,year,amount\n111111,3.5,2012,700\n111112,3.5,2011,600\n222221,4.0,2012,222\"\"\")\n\nsd = pd.read_csv(incsv, index_col=['col2','year'])\n\nsd", | |
"language": "python", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"html": "<div style=\"max-height:1000px;max-width:1500px;overflow:auto;\">\n<table border=\"1\" class=\"dataframe\">\n <thead>\n <tr style=\"text-align: right;\">\n <th></th>\n <th></th>\n <th>col1</th>\n <th>amount</th>\n </tr>\n <tr>\n <th>col2</th>\n <th>year</th>\n <th></th>\n <th></th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <td rowspan=\"2\" valign=\"top\"><strong>3.5</strong></td>\n <td><strong>2012</strong></td>\n <td> 111111</td>\n <td> 700</td>\n </tr>\n <tr>\n <td><strong>2011</strong></td>\n <td> 111112</td>\n <td> 600</td>\n </tr>\n <tr>\n <td><strong>4.0</strong></td>\n <td><strong>2012</strong></td>\n <td> 222221</td>\n <td> 222</td>\n </tr>\n </tbody>\n</table>\n</div>", | |
"output_type": "pyout", | |
"prompt_number": 2, | |
"text": " col1 amount\ncol2 year \n3.5 2012 111111 700\n 2011 111112 600\n4.0 2012 222221 222" | |
} | |
], | |
"prompt_number": 2 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": "sd.ix[(4.0,2012)]", | |
"language": "python", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"output_type": "pyout", | |
"prompt_number": 3, | |
"text": " col1 222221\n amount 222\nName: (4.0, 2012)" | |
} | |
], | |
"prompt_number": 3 | |
} | |
], | |
"metadata": {} | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment