Created
July 30, 2014 04:02
-
-
Save T0MASD/2d27c9dcd6e094072351 to your computer and use it in GitHub Desktop.
pandas rollup question
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 rollup" | |
}, | |
"nbformat": 3, | |
"nbformat_minor": 0, | |
"worksheets": [ | |
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": "import pandas as pd\nfrom pandas.tslib import Timestamp\nfrom pandas import DataFrame\n", | |
"language": "python", | |
"metadata": {}, | |
"outputs": [], | |
"prompt_number": 8 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": "data = [\n{u'bug_id': 1, u'bug_when': Timestamp('1998-11-01 21:56:09'), u'removed': '', u'added': 'NEW'},\n{u'bug_id': 2, u'bug_when': Timestamp('1998-11-02 14:20:17'), u'removed': '', u'added': 'NEW'},\n{u'bug_id': 1, u'bug_when': Timestamp('1998-11-03 22:02:25'), u'removed': u'NEW', u'added': u'CLOSED'},\n{u'bug_id': 3, u'bug_when': Timestamp('1998-11-04 10:02:01'), u'removed': u'', u'added': u'NEW'},\n{u'bug_id': 2, u'bug_when': Timestamp('1998-11-04 10:02:02'), u'removed': u'NEW', u'added': u'CLOSED'},\n{u'bug_id': 3, u'bug_when': Timestamp('1998-11-05 15:03:21'), u'removed': u'NEW', u'added': u'CLOSED'}\n]", | |
"language": "python", | |
"metadata": {}, | |
"outputs": [], | |
"prompt_number": 23 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": "df = DataFrame(data=data, columns=['bug_id','bug_when','removed','added'])", | |
"language": "python", | |
"metadata": {}, | |
"outputs": [], | |
"prompt_number": 24 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": "df.head(n=6)", | |
"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>bug_id</th>\n <th>bug_when</th>\n <th>removed</th>\n <th>added</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <td><strong>0</strong></td>\n <td> 1</td>\n <td> 1998-11-01 21:56:09</td>\n <td> </td>\n <td> NEW</td>\n </tr>\n <tr>\n <td><strong>1</strong></td>\n <td> 2</td>\n <td> 1998-11-02 14:20:17</td>\n <td> </td>\n <td> NEW</td>\n </tr>\n <tr>\n <td><strong>2</strong></td>\n <td> 1</td>\n <td> 1998-11-03 22:02:25</td>\n <td> NEW</td>\n <td> CLOSED</td>\n </tr>\n <tr>\n <td><strong>3</strong></td>\n <td> 3</td>\n <td> 1998-11-04 10:02:01</td>\n <td> </td>\n <td> NEW</td>\n </tr>\n <tr>\n <td><strong>4</strong></td>\n <td> 2</td>\n <td> 1998-11-04 10:02:02</td>\n <td> NEW</td>\n <td> CLOSED</td>\n </tr>\n <tr>\n <td><strong>5</strong></td>\n <td> 3</td>\n <td> 1998-11-05 15:03:21</td>\n <td> NEW</td>\n <td> CLOSED</td>\n </tr>\n </tbody>\n</table>\n</div>", | |
"output_type": "pyout", | |
"prompt_number": 26, | |
"text": " bug_id bug_when removed added\n0 1 1998-11-01 21:56:09 NEW\n1 2 1998-11-02 14:20:17 NEW\n2 1 1998-11-03 22:02:25 NEW CLOSED\n3 3 1998-11-04 10:02:01 NEW\n4 2 1998-11-04 10:02:02 NEW CLOSED\n5 3 1998-11-05 15:03:21 NEW CLOSED" | |
} | |
], | |
"prompt_number": 26 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": "", | |
"language": "python", | |
"metadata": {}, | |
"outputs": [] | |
} | |
], | |
"metadata": {} | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment