2015-02-11 06:44:21 +08:00
|
|
|
{
|
|
|
|
"metadata": {
|
|
|
|
"name": "",
|
2015-02-14 19:42:44 +08:00
|
|
|
"signature": "sha256:b619f1fd1f2d4495d6a2fe9d048c09b7319b119d4e10a5b2348f0ac6f380a27c"
|
2015-02-11 06:44:21 +08:00
|
|
|
},
|
|
|
|
"nbformat": 3,
|
|
|
|
"nbformat_minor": 0,
|
|
|
|
"worksheets": [
|
|
|
|
{
|
|
|
|
"cells": [
|
|
|
|
{
|
|
|
|
"cell_type": "markdown",
|
|
|
|
"metadata": {},
|
|
|
|
"source": [
|
|
|
|
"# Pandas Cleaning\n",
|
|
|
|
"* Clean\n",
|
|
|
|
"* Transform\n",
|
|
|
|
"* Merge\n",
|
2015-02-14 04:51:25 +08:00
|
|
|
"* Reshape\n",
|
|
|
|
"* Concatenate"
|
2015-02-11 06:44:21 +08:00
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"collapsed": false,
|
|
|
|
"input": [
|
|
|
|
"from pandas import Series, DataFrame\n",
|
|
|
|
"import pandas as pd"
|
|
|
|
],
|
|
|
|
"language": "python",
|
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"prompt_number": 1
|
|
|
|
},
|
2015-02-12 05:51:18 +08:00
|
|
|
{
|
|
|
|
"cell_type": "markdown",
|
|
|
|
"metadata": {},
|
|
|
|
"source": [
|
2015-02-14 04:51:25 +08:00
|
|
|
"Check for matching values in a specific column for replacement:"
|
2015-02-12 05:51:18 +08:00
|
|
|
]
|
|
|
|
},
|
2015-02-11 06:44:21 +08:00
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"collapsed": false,
|
|
|
|
"input": [
|
|
|
|
"data_1 = {'state' : ['VA', 'VA', 'VA', 'MD', 'MD'],\n",
|
|
|
|
" 'year' : [2012, 2013, 2014, 2014, 2015],\n",
|
2015-02-14 19:42:44 +08:00
|
|
|
" 'population' : [5.0, 5.1, 5.2, 4.0, 4.1]}\n",
|
2015-02-11 06:44:21 +08:00
|
|
|
"df_1 = DataFrame(data_1)\n",
|
|
|
|
"df_1"
|
|
|
|
],
|
|
|
|
"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",
|
2015-02-14 19:42:44 +08:00
|
|
|
" <th>population</th>\n",
|
2015-02-11 06:44:21 +08:00
|
|
|
" <th>state</th>\n",
|
|
|
|
" <th>year</th>\n",
|
|
|
|
" </tr>\n",
|
|
|
|
" </thead>\n",
|
|
|
|
" <tbody>\n",
|
|
|
|
" <tr>\n",
|
|
|
|
" <th>0</th>\n",
|
|
|
|
" <td> 5.0</td>\n",
|
|
|
|
" <td> VA</td>\n",
|
|
|
|
" <td> 2012</td>\n",
|
|
|
|
" </tr>\n",
|
|
|
|
" <tr>\n",
|
|
|
|
" <th>1</th>\n",
|
|
|
|
" <td> 5.1</td>\n",
|
|
|
|
" <td> VA</td>\n",
|
|
|
|
" <td> 2013</td>\n",
|
|
|
|
" </tr>\n",
|
|
|
|
" <tr>\n",
|
|
|
|
" <th>2</th>\n",
|
|
|
|
" <td> 5.2</td>\n",
|
|
|
|
" <td> VA</td>\n",
|
|
|
|
" <td> 2014</td>\n",
|
|
|
|
" </tr>\n",
|
|
|
|
" <tr>\n",
|
|
|
|
" <th>3</th>\n",
|
|
|
|
" <td> 4.0</td>\n",
|
|
|
|
" <td> MD</td>\n",
|
|
|
|
" <td> 2014</td>\n",
|
|
|
|
" </tr>\n",
|
|
|
|
" <tr>\n",
|
|
|
|
" <th>4</th>\n",
|
|
|
|
" <td> 4.1</td>\n",
|
|
|
|
" <td> MD</td>\n",
|
|
|
|
" <td> 2015</td>\n",
|
|
|
|
" </tr>\n",
|
|
|
|
" </tbody>\n",
|
|
|
|
"</table>\n",
|
|
|
|
"</div>"
|
|
|
|
],
|
|
|
|
"metadata": {},
|
|
|
|
"output_type": "pyout",
|
|
|
|
"prompt_number": 2,
|
|
|
|
"text": [
|
2015-02-14 19:42:44 +08:00
|
|
|
" population state year\n",
|
|
|
|
"0 5.0 VA 2012\n",
|
|
|
|
"1 5.1 VA 2013\n",
|
|
|
|
"2 5.2 VA 2014\n",
|
|
|
|
"3 4.0 MD 2014\n",
|
|
|
|
"4 4.1 MD 2015"
|
2015-02-11 06:44:21 +08:00
|
|
|
]
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"prompt_number": 2
|
|
|
|
},
|
2015-02-14 04:51:25 +08:00
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"collapsed": false,
|
|
|
|
"input": [
|
|
|
|
"df_1[df_1['state'] == 'VA']"
|
|
|
|
],
|
|
|
|
"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",
|
2015-02-14 19:42:44 +08:00
|
|
|
" <th>population</th>\n",
|
2015-02-14 04:51:25 +08:00
|
|
|
" <th>state</th>\n",
|
|
|
|
" <th>year</th>\n",
|
|
|
|
" </tr>\n",
|
|
|
|
" </thead>\n",
|
|
|
|
" <tbody>\n",
|
|
|
|
" <tr>\n",
|
|
|
|
" <th>0</th>\n",
|
|
|
|
" <td> 5.0</td>\n",
|
|
|
|
" <td> VA</td>\n",
|
|
|
|
" <td> 2012</td>\n",
|
|
|
|
" </tr>\n",
|
|
|
|
" <tr>\n",
|
|
|
|
" <th>1</th>\n",
|
|
|
|
" <td> 5.1</td>\n",
|
|
|
|
" <td> VA</td>\n",
|
|
|
|
" <td> 2013</td>\n",
|
|
|
|
" </tr>\n",
|
|
|
|
" <tr>\n",
|
|
|
|
" <th>2</th>\n",
|
|
|
|
" <td> 5.2</td>\n",
|
|
|
|
" <td> VA</td>\n",
|
|
|
|
" <td> 2014</td>\n",
|
|
|
|
" </tr>\n",
|
|
|
|
" </tbody>\n",
|
|
|
|
"</table>\n",
|
|
|
|
"</div>"
|
|
|
|
],
|
|
|
|
"metadata": {},
|
|
|
|
"output_type": "pyout",
|
|
|
|
"prompt_number": 3,
|
|
|
|
"text": [
|
2015-02-14 19:42:44 +08:00
|
|
|
" population state year\n",
|
|
|
|
"0 5.0 VA 2012\n",
|
|
|
|
"1 5.1 VA 2013\n",
|
|
|
|
"2 5.2 VA 2014"
|
2015-02-14 04:51:25 +08:00
|
|
|
]
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"prompt_number": 3
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "markdown",
|
|
|
|
"metadata": {},
|
|
|
|
"source": [
|
|
|
|
"Replace all occurrences of a string with another string, in place (no copy):"
|
|
|
|
]
|
|
|
|
},
|
2015-02-11 06:44:21 +08:00
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"collapsed": false,
|
|
|
|
"input": [
|
|
|
|
"df_1.replace('VA', 'VIRGINIA', inplace=True)\n",
|
|
|
|
"df_1"
|
|
|
|
],
|
|
|
|
"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",
|
2015-02-14 19:42:44 +08:00
|
|
|
" <th>population</th>\n",
|
2015-02-11 06:44:21 +08:00
|
|
|
" <th>state</th>\n",
|
|
|
|
" <th>year</th>\n",
|
|
|
|
" </tr>\n",
|
|
|
|
" </thead>\n",
|
|
|
|
" <tbody>\n",
|
|
|
|
" <tr>\n",
|
|
|
|
" <th>0</th>\n",
|
|
|
|
" <td> 5.0</td>\n",
|
|
|
|
" <td> VIRGINIA</td>\n",
|
|
|
|
" <td> 2012</td>\n",
|
|
|
|
" </tr>\n",
|
|
|
|
" <tr>\n",
|
|
|
|
" <th>1</th>\n",
|
|
|
|
" <td> 5.1</td>\n",
|
|
|
|
" <td> VIRGINIA</td>\n",
|
|
|
|
" <td> 2013</td>\n",
|
|
|
|
" </tr>\n",
|
|
|
|
" <tr>\n",
|
|
|
|
" <th>2</th>\n",
|
|
|
|
" <td> 5.2</td>\n",
|
|
|
|
" <td> VIRGINIA</td>\n",
|
|
|
|
" <td> 2014</td>\n",
|
|
|
|
" </tr>\n",
|
|
|
|
" <tr>\n",
|
|
|
|
" <th>3</th>\n",
|
|
|
|
" <td> 4.0</td>\n",
|
|
|
|
" <td> MD</td>\n",
|
|
|
|
" <td> 2014</td>\n",
|
|
|
|
" </tr>\n",
|
|
|
|
" <tr>\n",
|
|
|
|
" <th>4</th>\n",
|
|
|
|
" <td> 4.1</td>\n",
|
|
|
|
" <td> MD</td>\n",
|
|
|
|
" <td> 2015</td>\n",
|
|
|
|
" </tr>\n",
|
|
|
|
" </tbody>\n",
|
|
|
|
"</table>\n",
|
|
|
|
"</div>"
|
|
|
|
],
|
|
|
|
"metadata": {},
|
|
|
|
"output_type": "pyout",
|
2015-02-14 04:51:25 +08:00
|
|
|
"prompt_number": 4,
|
2015-02-11 06:44:21 +08:00
|
|
|
"text": [
|
2015-02-14 19:42:44 +08:00
|
|
|
" population state year\n",
|
|
|
|
"0 5.0 VIRGINIA 2012\n",
|
|
|
|
"1 5.1 VIRGINIA 2013\n",
|
|
|
|
"2 5.2 VIRGINIA 2014\n",
|
|
|
|
"3 4.0 MD 2014\n",
|
|
|
|
"4 4.1 MD 2015"
|
2015-02-11 06:44:21 +08:00
|
|
|
]
|
|
|
|
}
|
|
|
|
],
|
2015-02-14 04:51:25 +08:00
|
|
|
"prompt_number": 4
|
2015-02-11 06:44:21 +08:00
|
|
|
},
|
2015-02-12 05:51:18 +08:00
|
|
|
{
|
|
|
|
"cell_type": "markdown",
|
|
|
|
"metadata": {},
|
|
|
|
"source": [
|
|
|
|
"In a specified column, replace all occurrences of a string with another string, in place (no copy):"
|
|
|
|
]
|
|
|
|
},
|
2015-02-11 06:44:21 +08:00
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"collapsed": false,
|
|
|
|
"input": [
|
2015-02-14 04:54:23 +08:00
|
|
|
"df_1.replace({'state' : { 'MD' : 'MARYLAND' }}, inplace=True)\n",
|
2015-02-14 04:51:25 +08:00
|
|
|
"df_1"
|
2015-02-11 06:44:21 +08:00
|
|
|
],
|
|
|
|
"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",
|
2015-02-14 19:42:44 +08:00
|
|
|
" <th>population</th>\n",
|
2015-02-11 06:44:21 +08:00
|
|
|
" <th>state</th>\n",
|
|
|
|
" <th>year</th>\n",
|
|
|
|
" </tr>\n",
|
|
|
|
" </thead>\n",
|
|
|
|
" <tbody>\n",
|
|
|
|
" <tr>\n",
|
|
|
|
" <th>0</th>\n",
|
|
|
|
" <td> 5.0</td>\n",
|
|
|
|
" <td> VIRGINIA</td>\n",
|
|
|
|
" <td> 2012</td>\n",
|
|
|
|
" </tr>\n",
|
|
|
|
" <tr>\n",
|
|
|
|
" <th>1</th>\n",
|
|
|
|
" <td> 5.1</td>\n",
|
|
|
|
" <td> VIRGINIA</td>\n",
|
|
|
|
" <td> 2013</td>\n",
|
|
|
|
" </tr>\n",
|
|
|
|
" <tr>\n",
|
|
|
|
" <th>2</th>\n",
|
|
|
|
" <td> 5.2</td>\n",
|
|
|
|
" <td> VIRGINIA</td>\n",
|
|
|
|
" <td> 2014</td>\n",
|
|
|
|
" </tr>\n",
|
|
|
|
" <tr>\n",
|
|
|
|
" <th>3</th>\n",
|
|
|
|
" <td> 4.0</td>\n",
|
2015-02-14 04:54:23 +08:00
|
|
|
" <td> MARYLAND</td>\n",
|
2015-02-11 06:44:21 +08:00
|
|
|
" <td> 2014</td>\n",
|
|
|
|
" </tr>\n",
|
|
|
|
" <tr>\n",
|
|
|
|
" <th>4</th>\n",
|
|
|
|
" <td> 4.1</td>\n",
|
2015-02-14 04:54:23 +08:00
|
|
|
" <td> MARYLAND</td>\n",
|
2015-02-11 06:44:21 +08:00
|
|
|
" <td> 2015</td>\n",
|
|
|
|
" </tr>\n",
|
|
|
|
" </tbody>\n",
|
|
|
|
"</table>\n",
|
|
|
|
"</div>"
|
|
|
|
],
|
|
|
|
"metadata": {},
|
|
|
|
"output_type": "pyout",
|
2015-02-14 04:51:25 +08:00
|
|
|
"prompt_number": 5,
|
2015-02-11 06:44:21 +08:00
|
|
|
"text": [
|
2015-02-14 19:42:44 +08:00
|
|
|
" population state year\n",
|
|
|
|
"0 5.0 VIRGINIA 2012\n",
|
|
|
|
"1 5.1 VIRGINIA 2013\n",
|
|
|
|
"2 5.2 VIRGINIA 2014\n",
|
|
|
|
"3 4.0 MARYLAND 2014\n",
|
|
|
|
"4 4.1 MARYLAND 2015"
|
2015-02-11 06:44:21 +08:00
|
|
|
]
|
|
|
|
}
|
|
|
|
],
|
2015-02-14 04:51:25 +08:00
|
|
|
"prompt_number": 5
|
2015-02-14 04:53:15 +08:00
|
|
|
},
|
2015-02-14 19:42:44 +08:00
|
|
|
{
|
|
|
|
"cell_type": "markdown",
|
|
|
|
"metadata": {},
|
|
|
|
"source": [
|
|
|
|
"Drop the 'population' column and return a copy of the DataFrame:"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"collapsed": false,
|
|
|
|
"input": [
|
|
|
|
"df_2 = df_1.drop('population', axis=1)\n",
|
|
|
|
"df_2"
|
|
|
|
],
|
|
|
|
"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>state</th>\n",
|
|
|
|
" <th>year</th>\n",
|
|
|
|
" </tr>\n",
|
|
|
|
" </thead>\n",
|
|
|
|
" <tbody>\n",
|
|
|
|
" <tr>\n",
|
|
|
|
" <th>0</th>\n",
|
|
|
|
" <td> VIRGINIA</td>\n",
|
|
|
|
" <td> 2012</td>\n",
|
|
|
|
" </tr>\n",
|
|
|
|
" <tr>\n",
|
|
|
|
" <th>1</th>\n",
|
|
|
|
" <td> VIRGINIA</td>\n",
|
|
|
|
" <td> 2013</td>\n",
|
|
|
|
" </tr>\n",
|
|
|
|
" <tr>\n",
|
|
|
|
" <th>2</th>\n",
|
|
|
|
" <td> VIRGINIA</td>\n",
|
|
|
|
" <td> 2014</td>\n",
|
|
|
|
" </tr>\n",
|
|
|
|
" <tr>\n",
|
|
|
|
" <th>3</th>\n",
|
|
|
|
" <td> MARYLAND</td>\n",
|
|
|
|
" <td> 2014</td>\n",
|
|
|
|
" </tr>\n",
|
|
|
|
" <tr>\n",
|
|
|
|
" <th>4</th>\n",
|
|
|
|
" <td> MARYLAND</td>\n",
|
|
|
|
" <td> 2015</td>\n",
|
|
|
|
" </tr>\n",
|
|
|
|
" </tbody>\n",
|
|
|
|
"</table>\n",
|
|
|
|
"</div>"
|
|
|
|
],
|
|
|
|
"metadata": {},
|
|
|
|
"output_type": "pyout",
|
|
|
|
"prompt_number": 6,
|
|
|
|
"text": [
|
|
|
|
" state year\n",
|
|
|
|
"0 VIRGINIA 2012\n",
|
|
|
|
"1 VIRGINIA 2013\n",
|
|
|
|
"2 VIRGINIA 2014\n",
|
|
|
|
"3 MARYLAND 2014\n",
|
|
|
|
"4 MARYLAND 2015"
|
|
|
|
]
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"prompt_number": 6
|
|
|
|
},
|
2015-02-14 04:53:15 +08:00
|
|
|
{
|
|
|
|
"cell_type": "markdown",
|
|
|
|
"metadata": {},
|
|
|
|
"source": [
|
|
|
|
"Concatenate two DataFrames:"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"collapsed": false,
|
|
|
|
"input": [
|
|
|
|
"data_2 = {'state' : ['NY', 'NY', 'NY', 'FL', 'FL'],\n",
|
|
|
|
" 'year' : [2012, 2013, 2014, 2014, 2015],\n",
|
2015-02-14 19:42:44 +08:00
|
|
|
" 'population' : [6.0, 6.1, 6.2, 3.0, 3.1]}\n",
|
|
|
|
"df_3 = DataFrame(data_2)\n",
|
|
|
|
"df_3"
|
2015-02-14 04:53:15 +08:00
|
|
|
],
|
|
|
|
"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",
|
2015-02-14 19:42:44 +08:00
|
|
|
" <th>population</th>\n",
|
2015-02-14 04:53:15 +08:00
|
|
|
" <th>state</th>\n",
|
|
|
|
" <th>year</th>\n",
|
|
|
|
" </tr>\n",
|
|
|
|
" </thead>\n",
|
|
|
|
" <tbody>\n",
|
|
|
|
" <tr>\n",
|
|
|
|
" <th>0</th>\n",
|
|
|
|
" <td> 6.0</td>\n",
|
|
|
|
" <td> NY</td>\n",
|
|
|
|
" <td> 2012</td>\n",
|
|
|
|
" </tr>\n",
|
|
|
|
" <tr>\n",
|
|
|
|
" <th>1</th>\n",
|
|
|
|
" <td> 6.1</td>\n",
|
|
|
|
" <td> NY</td>\n",
|
|
|
|
" <td> 2013</td>\n",
|
|
|
|
" </tr>\n",
|
|
|
|
" <tr>\n",
|
|
|
|
" <th>2</th>\n",
|
|
|
|
" <td> 6.2</td>\n",
|
|
|
|
" <td> NY</td>\n",
|
|
|
|
" <td> 2014</td>\n",
|
|
|
|
" </tr>\n",
|
|
|
|
" <tr>\n",
|
|
|
|
" <th>3</th>\n",
|
|
|
|
" <td> 3.0</td>\n",
|
|
|
|
" <td> FL</td>\n",
|
|
|
|
" <td> 2014</td>\n",
|
|
|
|
" </tr>\n",
|
|
|
|
" <tr>\n",
|
|
|
|
" <th>4</th>\n",
|
|
|
|
" <td> 3.1</td>\n",
|
|
|
|
" <td> FL</td>\n",
|
|
|
|
" <td> 2015</td>\n",
|
|
|
|
" </tr>\n",
|
|
|
|
" </tbody>\n",
|
|
|
|
"</table>\n",
|
|
|
|
"</div>"
|
|
|
|
],
|
|
|
|
"metadata": {},
|
|
|
|
"output_type": "pyout",
|
2015-02-14 19:42:44 +08:00
|
|
|
"prompt_number": 7,
|
2015-02-14 04:53:15 +08:00
|
|
|
"text": [
|
2015-02-14 19:42:44 +08:00
|
|
|
" population state year\n",
|
|
|
|
"0 6.0 NY 2012\n",
|
|
|
|
"1 6.1 NY 2013\n",
|
|
|
|
"2 6.2 NY 2014\n",
|
|
|
|
"3 3.0 FL 2014\n",
|
|
|
|
"4 3.1 FL 2015"
|
2015-02-14 04:53:15 +08:00
|
|
|
]
|
|
|
|
}
|
|
|
|
],
|
2015-02-14 19:42:44 +08:00
|
|
|
"prompt_number": 7
|
2015-02-14 04:53:15 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"collapsed": false,
|
|
|
|
"input": [
|
2015-02-14 19:42:44 +08:00
|
|
|
"df_4 = pd.concat([df_1, df_3])\n",
|
|
|
|
"df_4"
|
2015-02-14 04:53:15 +08:00
|
|
|
],
|
|
|
|
"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",
|
2015-02-14 19:42:44 +08:00
|
|
|
" <th>population</th>\n",
|
2015-02-14 04:53:15 +08:00
|
|
|
" <th>state</th>\n",
|
|
|
|
" <th>year</th>\n",
|
|
|
|
" </tr>\n",
|
|
|
|
" </thead>\n",
|
|
|
|
" <tbody>\n",
|
|
|
|
" <tr>\n",
|
|
|
|
" <th>0</th>\n",
|
|
|
|
" <td> 5.0</td>\n",
|
|
|
|
" <td> VIRGINIA</td>\n",
|
|
|
|
" <td> 2012</td>\n",
|
|
|
|
" </tr>\n",
|
|
|
|
" <tr>\n",
|
|
|
|
" <th>1</th>\n",
|
|
|
|
" <td> 5.1</td>\n",
|
|
|
|
" <td> VIRGINIA</td>\n",
|
|
|
|
" <td> 2013</td>\n",
|
|
|
|
" </tr>\n",
|
|
|
|
" <tr>\n",
|
|
|
|
" <th>2</th>\n",
|
|
|
|
" <td> 5.2</td>\n",
|
|
|
|
" <td> VIRGINIA</td>\n",
|
|
|
|
" <td> 2014</td>\n",
|
|
|
|
" </tr>\n",
|
|
|
|
" <tr>\n",
|
|
|
|
" <th>3</th>\n",
|
|
|
|
" <td> 4.0</td>\n",
|
2015-02-14 04:54:23 +08:00
|
|
|
" <td> MARYLAND</td>\n",
|
2015-02-14 04:53:15 +08:00
|
|
|
" <td> 2014</td>\n",
|
|
|
|
" </tr>\n",
|
|
|
|
" <tr>\n",
|
|
|
|
" <th>4</th>\n",
|
|
|
|
" <td> 4.1</td>\n",
|
2015-02-14 04:54:23 +08:00
|
|
|
" <td> MARYLAND</td>\n",
|
2015-02-14 04:53:15 +08:00
|
|
|
" <td> 2015</td>\n",
|
|
|
|
" </tr>\n",
|
|
|
|
" <tr>\n",
|
|
|
|
" <th>0</th>\n",
|
|
|
|
" <td> 6.0</td>\n",
|
|
|
|
" <td> NY</td>\n",
|
|
|
|
" <td> 2012</td>\n",
|
|
|
|
" </tr>\n",
|
|
|
|
" <tr>\n",
|
|
|
|
" <th>1</th>\n",
|
|
|
|
" <td> 6.1</td>\n",
|
|
|
|
" <td> NY</td>\n",
|
|
|
|
" <td> 2013</td>\n",
|
|
|
|
" </tr>\n",
|
|
|
|
" <tr>\n",
|
|
|
|
" <th>2</th>\n",
|
|
|
|
" <td> 6.2</td>\n",
|
|
|
|
" <td> NY</td>\n",
|
|
|
|
" <td> 2014</td>\n",
|
|
|
|
" </tr>\n",
|
|
|
|
" <tr>\n",
|
|
|
|
" <th>3</th>\n",
|
|
|
|
" <td> 3.0</td>\n",
|
|
|
|
" <td> FL</td>\n",
|
|
|
|
" <td> 2014</td>\n",
|
|
|
|
" </tr>\n",
|
|
|
|
" <tr>\n",
|
|
|
|
" <th>4</th>\n",
|
|
|
|
" <td> 3.1</td>\n",
|
|
|
|
" <td> FL</td>\n",
|
|
|
|
" <td> 2015</td>\n",
|
|
|
|
" </tr>\n",
|
|
|
|
" </tbody>\n",
|
|
|
|
"</table>\n",
|
|
|
|
"</div>"
|
|
|
|
],
|
|
|
|
"metadata": {},
|
|
|
|
"output_type": "pyout",
|
2015-02-14 19:42:44 +08:00
|
|
|
"prompt_number": 8,
|
2015-02-14 04:53:15 +08:00
|
|
|
"text": [
|
2015-02-14 19:42:44 +08:00
|
|
|
" population state year\n",
|
|
|
|
"0 5.0 VIRGINIA 2012\n",
|
|
|
|
"1 5.1 VIRGINIA 2013\n",
|
|
|
|
"2 5.2 VIRGINIA 2014\n",
|
|
|
|
"3 4.0 MARYLAND 2014\n",
|
|
|
|
"4 4.1 MARYLAND 2015\n",
|
|
|
|
"0 6.0 NY 2012\n",
|
|
|
|
"1 6.1 NY 2013\n",
|
|
|
|
"2 6.2 NY 2014\n",
|
|
|
|
"3 3.0 FL 2014\n",
|
|
|
|
"4 3.1 FL 2015"
|
2015-02-14 04:53:15 +08:00
|
|
|
]
|
|
|
|
}
|
|
|
|
],
|
2015-02-14 19:42:44 +08:00
|
|
|
"prompt_number": 8
|
2015-02-14 04:53:15 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"collapsed": false,
|
|
|
|
"input": [],
|
|
|
|
"language": "python",
|
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
2015-02-14 19:42:44 +08:00
|
|
|
"prompt_number": 8
|
2015-02-11 06:44:21 +08:00
|
|
|
}
|
|
|
|
],
|
|
|
|
"metadata": {}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|