Created
April 23, 2013 00:15
-
-
Save michaelaye/5439745 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": "Adding dataframes" | |
}, | |
"nbformat": 3, | |
"nbformat_minor": 0, | |
"worksheets": [ | |
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"import pandas as pd" | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [], | |
"prompt_number": 2 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"times = pd.date_range(start='now',periods=10)" | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [], | |
"prompt_number": 4 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"list(times)" | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"output_type": "pyout", | |
"prompt_number": 6, | |
"text": [ | |
"[<Timestamp: 2013-04-22 23:58:37>,\n", | |
" <Timestamp: 2013-04-23 23:58:37>,\n", | |
" <Timestamp: 2013-04-24 23:58:37>,\n", | |
" <Timestamp: 2013-04-25 23:58:37>,\n", | |
" <Timestamp: 2013-04-26 23:58:37>,\n", | |
" <Timestamp: 2013-04-27 23:58:37>,\n", | |
" <Timestamp: 2013-04-28 23:58:37>,\n", | |
" <Timestamp: 2013-04-29 23:58:37>,\n", | |
" <Timestamp: 2013-04-30 23:58:37>,\n", | |
" <Timestamp: 2013-05-01 23:58:37>]" | |
] | |
} | |
], | |
"prompt_number": 6 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"df1 = pd.DataFrame(randn(10), index=times, columns=['a'])\n", | |
"df1" | |
], | |
"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>a</th>\n", | |
" </tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr>\n", | |
" <th>2013-04-22 23:58:37</th>\n", | |
" <td> 0.878587</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2013-04-23 23:58:37</th>\n", | |
" <td>-0.568220</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2013-04-24 23:58:37</th>\n", | |
" <td>-1.919558</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2013-04-25 23:58:37</th>\n", | |
" <td>-1.100338</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2013-04-26 23:58:37</th>\n", | |
" <td> 1.937008</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2013-04-27 23:58:37</th>\n", | |
" <td> 0.798509</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2013-04-28 23:58:37</th>\n", | |
" <td>-0.299917</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2013-04-29 23:58:37</th>\n", | |
" <td>-1.212948</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2013-04-30 23:58:37</th>\n", | |
" <td> 0.594491</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2013-05-01 23:58:37</th>\n", | |
" <td> 3.021651</td>\n", | |
" </tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"</div>" | |
], | |
"output_type": "pyout", | |
"prompt_number": 13, | |
"text": [ | |
" a\n", | |
"2013-04-22 23:58:37 0.878587\n", | |
"2013-04-23 23:58:37 -0.568220\n", | |
"2013-04-24 23:58:37 -1.919558\n", | |
"2013-04-25 23:58:37 -1.100338\n", | |
"2013-04-26 23:58:37 1.937008\n", | |
"2013-04-27 23:58:37 0.798509\n", | |
"2013-04-28 23:58:37 -0.299917\n", | |
"2013-04-29 23:58:37 -1.212948\n", | |
"2013-04-30 23:58:37 0.594491\n", | |
"2013-05-01 23:58:37 3.021651" | |
] | |
} | |
], | |
"prompt_number": 13 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"df2 = pd.DataFrame(randn(10), index=times, columns=['b'])\n", | |
"df2" | |
], | |
"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>b</th>\n", | |
" </tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr>\n", | |
" <th>2013-04-22 23:58:37</th>\n", | |
" <td>-0.634560</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2013-04-23 23:58:37</th>\n", | |
" <td> 0.886683</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2013-04-24 23:58:37</th>\n", | |
" <td> 0.128338</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2013-04-25 23:58:37</th>\n", | |
" <td>-0.874129</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2013-04-26 23:58:37</th>\n", | |
" <td>-0.331452</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2013-04-27 23:58:37</th>\n", | |
" <td>-0.322004</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2013-04-28 23:58:37</th>\n", | |
" <td>-0.816075</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2013-04-29 23:58:37</th>\n", | |
" <td>-0.126601</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2013-04-30 23:58:37</th>\n", | |
" <td>-0.203237</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2013-05-01 23:58:37</th>\n", | |
" <td> 0.625410</td>\n", | |
" </tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"</div>" | |
], | |
"output_type": "pyout", | |
"prompt_number": 14, | |
"text": [ | |
" b\n", | |
"2013-04-22 23:58:37 -0.634560\n", | |
"2013-04-23 23:58:37 0.886683\n", | |
"2013-04-24 23:58:37 0.128338\n", | |
"2013-04-25 23:58:37 -0.874129\n", | |
"2013-04-26 23:58:37 -0.331452\n", | |
"2013-04-27 23:58:37 -0.322004\n", | |
"2013-04-28 23:58:37 -0.816075\n", | |
"2013-04-29 23:58:37 -0.126601\n", | |
"2013-04-30 23:58:37 -0.203237\n", | |
"2013-05-01 23:58:37 0.625410" | |
] | |
} | |
], | |
"prompt_number": 14 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"df1 + df2" | |
], | |
"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>a</th>\n", | |
" <th>b</th>\n", | |
" </tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr>\n", | |
" <th>2013-04-22 23:58:37</th>\n", | |
" <td>NaN</td>\n", | |
" <td>NaN</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2013-04-23 23:58:37</th>\n", | |
" <td>NaN</td>\n", | |
" <td>NaN</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2013-04-24 23:58:37</th>\n", | |
" <td>NaN</td>\n", | |
" <td>NaN</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2013-04-25 23:58:37</th>\n", | |
" <td>NaN</td>\n", | |
" <td>NaN</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2013-04-26 23:58:37</th>\n", | |
" <td>NaN</td>\n", | |
" <td>NaN</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2013-04-27 23:58:37</th>\n", | |
" <td>NaN</td>\n", | |
" <td>NaN</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2013-04-28 23:58:37</th>\n", | |
" <td>NaN</td>\n", | |
" <td>NaN</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2013-04-29 23:58:37</th>\n", | |
" <td>NaN</td>\n", | |
" <td>NaN</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2013-04-30 23:58:37</th>\n", | |
" <td>NaN</td>\n", | |
" <td>NaN</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2013-05-01 23:58:37</th>\n", | |
" <td>NaN</td>\n", | |
" <td>NaN</td>\n", | |
" </tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"</div>" | |
], | |
"output_type": "pyout", | |
"prompt_number": 15, | |
"text": [ | |
" a b\n", | |
"2013-04-22 23:58:37 NaN NaN\n", | |
"2013-04-23 23:58:37 NaN NaN\n", | |
"2013-04-24 23:58:37 NaN NaN\n", | |
"2013-04-25 23:58:37 NaN NaN\n", | |
"2013-04-26 23:58:37 NaN NaN\n", | |
"2013-04-27 23:58:37 NaN NaN\n", | |
"2013-04-28 23:58:37 NaN NaN\n", | |
"2013-04-29 23:58:37 NaN NaN\n", | |
"2013-04-30 23:58:37 NaN NaN\n", | |
"2013-05-01 23:58:37 NaN NaN" | |
] | |
} | |
], | |
"prompt_number": 15 | |
}, | |
{ | |
"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