python-pour-finance/05-Sources-Données/.ipynb_checkpoints/2-Quandl-checkpoint.ipynb

959 lines
81 KiB
Plaintext
Raw Normal View History

2023-08-21 15:12:19 +00:00
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Quandl\n",
"More info:\n",
"https://www.quandl.com/tools/python"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import numpy as np\n",
"import pandas as pd\n",
"import matplotlib.pyplot as plt\n",
"%matplotlib inline"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import quandl"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Make a Basic Data Call\n",
"This call gets the WTI Crude Oil price from the US Department of Energy:"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
"mydata = quandl.get(\"EIA/PET_RWTC_D\")"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style>\n",
" .dataframe thead tr:only-child th {\n",
" text-align: right;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: left;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Value</th>\n",
" </tr>\n",
" <tr>\n",
" <th>Date</th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>1986-01-02</th>\n",
" <td>25.56</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1986-01-03</th>\n",
" <td>26.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1986-01-06</th>\n",
" <td>26.53</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1986-01-07</th>\n",
" <td>25.85</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1986-01-08</th>\n",
" <td>25.87</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Value\n",
"Date \n",
"1986-01-02 25.56\n",
"1986-01-03 26.00\n",
"1986-01-06 26.53\n",
"1986-01-07 25.85\n",
"1986-01-08 25.87"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"mydata.head()"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<matplotlib.axes._subplots.AxesSubplot at 0x2ae067cab70>"
]
},
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAskAAAFiCAYAAAAEBkVdAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzs3XeAVOXVBvDnnbKdhV12qQssTTpIEcWGCAp2TWxoEjUm\nGqMxxkRjiZpm4hcTNc3EjiZRLLEGO4IoIggiSpW2wC5tYdm+s9Pe74+Ze+femXun7057fv8wc+fO\nnXdhlz1z5rznCCkliIiIiIgowJLqBRARERERpRsGyUREREREQRgkExEREREFYZBMRERERBSEQTIR\nERERURAGyUREREREQRgkExEREREFYZBMRERERBSEQTIRERERURAGyUREREREQWypXgAAVFRUyOrq\n6lQvg4iIiIiy3Jo1aw5JKSsjnZcWQXJ1dTVWr16d6mUQERERUZYTQuyK5jyWWxARERERBWGQTERE\nREQUhEEyEREREVGQtKhJJiIiIqLkc7lcqK2thcPhSPVSul1BQQGqqqpgt9vjej6DZCIiIqIsVVtb\nix49eqC6uhpCiFQvp9tIKXH48GHU1tZi6NChcV2D5RZEREREWcrhcKB37945FSADgBACvXv3TiiD\nziCZiIiIKIvlWoCsSPTrZpBMRERERF1i1qxZeOedd3THHnroIVx33XWmzykpKenqZUWFQTIRERER\ndYn58+dj4cKFumMLFy7E/PnzU7Si6DFIJiIiIqIuceGFF2LR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vOr\nfd2xrG5j07wBKMuCILn
"text/plain": [
"<matplotlib.figure.Figure at 0x2ae06810b70>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"mydata.plot(figsize=(12,6))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Note that you need to know the \"Quandl code\" of each dataset you download. In the above example, it is \"EIA/PET_RWTC_D\"."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Change Formats\n",
"You can get the same data in a NumPy array:"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"mydata = quandl.get(\"EIA/PET_RWTC_D\", returns=\"numpy\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Specifying Data\n",
"\n",
"To set start and end dates:"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"mydata = quandl.get(\"FRED/GDP\", start_date=\"2001-12-31\", end_date=\"2005-12-31\")"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style>\n",
" .dataframe thead tr:only-child th {\n",
" text-align: right;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: left;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Value</th>\n",
" </tr>\n",
" <tr>\n",
" <th>Date</th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>2002-01-01</th>\n",
" <td>10834.4</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2002-04-01</th>\n",
" <td>10934.8</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2002-07-01</th>\n",
" <td>11037.1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2002-10-01</th>\n",
" <td>11103.8</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2003-01-01</th>\n",
" <td>11230.1</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Value\n",
"Date \n",
"2002-01-01 10834.4\n",
"2002-04-01 10934.8\n",
"2002-07-01 11037.1\n",
"2002-10-01 11103.8\n",
"2003-01-01 11230.1"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"mydata.head()"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"mydata = quandl.get([\"NSE/OIL.1\", \"WIKI/AAPL.4\"])"
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style>\n",
" .dataframe thead tr:only-child th {\n",
" text-align: right;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: left;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>NSE/OIL - Open</th>\n",
" <th>WIKI/AAPL - Close</th>\n",
" </tr>\n",
" <tr>\n",
" <th>Date</th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>1980-12-12</th>\n",
" <td>NaN</td>\n",
" <td>28.75</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1980-12-15</th>\n",
" <td>NaN</td>\n",
" <td>27.25</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1980-12-16</th>\n",
" <td>NaN</td>\n",
" <td>25.25</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1980-12-17</th>\n",
" <td>NaN</td>\n",
" <td>25.87</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1980-12-18</th>\n",
" <td>NaN</td>\n",
" <td>26.63</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" NSE/OIL - Open WIKI/AAPL - Close\n",
"Date \n",
"1980-12-12 NaN 28.75\n",
"1980-12-15 NaN 27.25\n",
"1980-12-16 NaN 25.25\n",
"1980-12-17 NaN 25.87\n",
"1980-12-18 NaN 26.63"
]
},
"execution_count": 21,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"mydata.head()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Usage Limits\n",
"The Quandl Python module is free. If you would like to make more than 50 calls a day, however, you will need to create a free Quandl account and set your API key:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"# EXAMPLE\n",
"quandl.ApiConfig.api_key = \"YOUR_KEY_HERE\"\n",
"mydata = quandl.get(\"FRED/GDP\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Database Codes\n",
"\n",
"Each database on Quandl has a short (3-to-6 character) database ID. For example:\n",
"\n",
"* CFTC Commitment of Traders Data: CFTC\n",
"* Core US Stock Fundamentals: SF1\n",
"* Federal Reserve Economic Data: FRED\n",
"\n",
"Each database contains many datasets. Datasets have their own IDs which are appended to their parent database ID, like this:\n",
"\n",
"* Commitment of traders for wheat: CFTC/W_F_ALL\n",
"* Market capitalization for Apple: SF1/AAPL_MARKETCAP\n",
"* US civilian unemployment rate: FRED/UNRATE\n",
"\n",
"You can download all dataset codes in a database in a single API call, by appending /codes to your database request. The call will return a ZIP file containing a CSV.\n",
"\n",
"### Databases\n",
"\n",
"\n",
"Every Quandl code has 2 parts: the database code (“WIKI”) which specifies where the data comes from, and the dataset code (“FB”) which identifies the specific time series you want.\n",
"\n",
"You can find Quandl codes on their website, using their data browser.\n",
"\n",
"https://www.quandl.com/search"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"# FOR STOCKS"
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"mydata = quandl.get('WIKI/FB',start_date='2015-01-01',end_date='2017-01-01')"
]
},
{
"cell_type": "code",
"execution_count": 24,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style>\n",
" .dataframe thead tr:only-child th {\n",
" text-align: right;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: left;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Open</th>\n",
" <th>High</th>\n",
" <th>Low</th>\n",
" <th>Close</th>\n",
" <th>Volume</th>\n",
" <th>Ex-Dividend</th>\n",
" <th>Split Ratio</th>\n",
" <th>Adj. Open</th>\n",
" <th>Adj. High</th>\n",
" <th>Adj. Low</th>\n",
" <th>Adj. Close</th>\n",
" <th>Adj. Volume</th>\n",
" </tr>\n",
" <tr>\n",
" <th>Date</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>2015-01-02</th>\n",
" <td>78.58</td>\n",
" <td>78.9300</td>\n",
" <td>77.700</td>\n",
" <td>78.450</td>\n",
" <td>18177475.0</td>\n",
" <td>0.0</td>\n",
" <td>1.0</td>\n",
" <td>78.58</td>\n",
" <td>78.9300</td>\n",
" <td>77.700</td>\n",
" <td>78.450</td>\n",
" <td>18177475.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2015-01-05</th>\n",
" <td>77.98</td>\n",
" <td>79.2455</td>\n",
" <td>76.860</td>\n",
" <td>77.190</td>\n",
" <td>26452191.0</td>\n",
" <td>0.0</td>\n",
" <td>1.0</td>\n",
" <td>77.98</td>\n",
" <td>79.2455</td>\n",
" <td>76.860</td>\n",
" <td>77.190</td>\n",
" <td>26452191.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2015-01-06</th>\n",
" <td>77.23</td>\n",
" <td>77.5900</td>\n",
" <td>75.365</td>\n",
" <td>76.150</td>\n",
" <td>27399288.0</td>\n",
" <td>0.0</td>\n",
" <td>1.0</td>\n",
" <td>77.23</td>\n",
" <td>77.5900</td>\n",
" <td>75.365</td>\n",
" <td>76.150</td>\n",
" <td>27399288.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2015-01-07</th>\n",
" <td>76.76</td>\n",
" <td>77.3600</td>\n",
" <td>75.820</td>\n",
" <td>76.150</td>\n",
" <td>22045333.0</td>\n",
" <td>0.0</td>\n",
" <td>1.0</td>\n",
" <td>76.76</td>\n",
" <td>77.3600</td>\n",
" <td>75.820</td>\n",
" <td>76.150</td>\n",
" <td>22045333.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2015-01-08</th>\n",
" <td>76.74</td>\n",
" <td>78.2300</td>\n",
" <td>76.080</td>\n",
" <td>78.175</td>\n",
" <td>23960953.0</td>\n",
" <td>0.0</td>\n",
" <td>1.0</td>\n",
" <td>76.74</td>\n",
" <td>78.2300</td>\n",
" <td>76.080</td>\n",
" <td>78.175</td>\n",
" <td>23960953.0</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Open High Low Close Volume Ex-Dividend \\\n",
"Date \n",
"2015-01-02 78.58 78.9300 77.700 78.450 18177475.0 0.0 \n",
"2015-01-05 77.98 79.2455 76.860 77.190 26452191.0 0.0 \n",
"2015-01-06 77.23 77.5900 75.365 76.150 27399288.0 0.0 \n",
"2015-01-07 76.76 77.3600 75.820 76.150 22045333.0 0.0 \n",
"2015-01-08 76.74 78.2300 76.080 78.175 23960953.0 0.0 \n",
"\n",
" Split Ratio Adj. Open Adj. High Adj. Low Adj. Close \\\n",
"Date \n",
"2015-01-02 1.0 78.58 78.9300 77.700 78.450 \n",
"2015-01-05 1.0 77.98 79.2455 76.860 77.190 \n",
"2015-01-06 1.0 77.23 77.5900 75.365 76.150 \n",
"2015-01-07 1.0 76.76 77.3600 75.820 76.150 \n",
"2015-01-08 1.0 76.74 78.2300 76.080 78.175 \n",
"\n",
" Adj. Volume \n",
"Date \n",
"2015-01-02 18177475.0 \n",
"2015-01-05 26452191.0 \n",
"2015-01-06 27399288.0 \n",
"2015-01-07 22045333.0 \n",
"2015-01-08 23960953.0 "
]
},
"execution_count": 24,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"mydata.head()"
]
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"mydata = quandl.get('WIKI/FB.1',start_date='2015-01-01',end_date='2017-01-01')"
]
},
{
"cell_type": "code",
"execution_count": 26,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style>\n",
" .dataframe thead tr:only-child th {\n",
" text-align: right;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: left;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Open</th>\n",
" </tr>\n",
" <tr>\n",
" <th>Date</th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>2015-01-02</th>\n",
" <td>78.58</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2015-01-05</th>\n",
" <td>77.98</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2015-01-06</th>\n",
" <td>77.23</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2015-01-07</th>\n",
" <td>76.76</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2015-01-08</th>\n",
" <td>76.74</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Open\n",
"Date \n",
"2015-01-02 78.58\n",
"2015-01-05 77.98\n",
"2015-01-06 77.23\n",
"2015-01-07 76.76\n",
"2015-01-08 76.74"
]
},
"execution_count": 26,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"mydata.head()"
]
},
{
"cell_type": "code",
"execution_count": 27,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"mydata = quandl.get('WIKI/FB.7',start_date='2015-01-01',end_date='2017-01-01')"
]
},
{
"cell_type": "code",
"execution_count": 28,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style>\n",
" .dataframe thead tr:only-child th {\n",
" text-align: right;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: left;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Split Ratio</th>\n",
" </tr>\n",
" <tr>\n",
" <th>Date</th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>2015-01-02</th>\n",
" <td>1.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2015-01-05</th>\n",
" <td>1.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2015-01-06</th>\n",
" <td>1.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2015-01-07</th>\n",
" <td>1.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2015-01-08</th>\n",
" <td>1.0</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Split Ratio\n",
"Date \n",
"2015-01-02 1.0\n",
"2015-01-05 1.0\n",
"2015-01-06 1.0\n",
"2015-01-07 1.0\n",
"2015-01-08 1.0"
]
},
"execution_count": 28,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"mydata.head()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Housing Price Example\n",
"\n",
"**Zillow Home Value Index (Metro): Zillow Rental Index - All Homes - San Francisco, CA**\n",
"\n",
"The Zillow Home Value Index is Zillow's estimate of the median market value of zillow rental index - all homes within the metro of San Francisco, CA. This data is calculated by Zillow Real Estate Research (www.zillow.com/research) using their database of 110 million homes."
]
},
{
"cell_type": "code",
"execution_count": 34,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"houses = quandl.get('ZILLOW/M11_ZRIAH')"
]
},
{
"cell_type": "code",
"execution_count": 35,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style>\n",
" .dataframe thead tr:only-child th {\n",
" text-align: right;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: left;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Value</th>\n",
" </tr>\n",
" <tr>\n",
" <th>Date</th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>2010-11-30</th>\n",
" <td>2240.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2010-12-31</th>\n",
" <td>2253.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2011-01-31</th>\n",
" <td>2275.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2011-02-28</th>\n",
" <td>2304.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2011-03-31</th>\n",
" <td>2333.0</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Value\n",
"Date \n",
"2010-11-30 2240.0\n",
"2010-12-31 2253.0\n",
"2011-01-31 2275.0\n",
"2011-02-28 2304.0\n",
"2011-03-31 2333.0"
]
},
"execution_count": 35,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"houses.head()"
]
},
{
"cell_type": "code",
"execution_count": 36,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<matplotlib.axes._subplots.AxesSubplot at 0x2ae07d12dd8>"
]
},
"execution_count": 36,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYEAAAEKCAYAAAD0Luk/AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3Xl8VdW5//HPQwYSCGFKGAMkyCSDiERERSvO2ipOtXCt\nilptq9Xa9rY/h95r21t763CtWltbblVoa6XU4WJVRLAOdQAMyDyGOQlDwhAIIZDh+f1xNjYikAAn\nOdP3/XqdV3bWHvKsnOQ8e6+19trm7oiISGJqEekAREQkcpQEREQSmJKAiEgCUxIQEUlgSgIiIglM\nSUBEJIEpCYiIJDAlARGRBKYkICKSwJIjHUBDsrKyPDc3N9JhiIjElLlz55a5e3ZD20V9EsjNzaWg\noCDSYYiIxBQzW9+Y7dQcJCKSwJQEREQSmJKAiEgCi/o+gUOprq6mqKiIqqqqSIfS7NLS0sjJySEl\nJSXSoYhIHIjJJFBUVESbNm3Izc3FzCIdTrNxd7Zt20ZRURF5eXmRDkdE4kBMNgdVVVXRsWPHhEoA\nAGZGx44dE/IKSESaRkwmASDhEsABiVpvEWkaMdkcJCLSXPbX1PHphh3M27CTrIxUTuiUwQlZGbRt\nFR/9ckoCx2D06NHcc889XHTRRZ+VPf7446xYsYKnn376kPtkZGRQUVHRXCGKyHEor6zmlU+L+Oeq\nMj5es43K/bVf2CYrI5UReR24fGh3zumfTVpKUgQiPX4NJgEzSwPeB1oG27/o7g/UW/8D4FEg293L\ngrJ7gVuAWuAud58elA8HJgLpwBvAdz0Gn3Q/btw4Jk+e/LkkMHnyZB5++OEIRiUi4TB3/XbuemE+\nxTv3ktuxFVefksOovlmMyO3Azr3VrCmtYHVpBSu3VPDuiq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Q7sxNKetPvgbELNJwN0T8s2N\nwRusRcJid1U105ds4dUFJXxYWEZtndO/cxt+eFF/RvbuwAnZGbRrFd9NPE0hJpNAWloa27ZtS7jp\npA88TyAtLS3SoYg0i/01dfxj+Ramzi/h7eVb2V9TR077dL55dm8uP7kbA7pkRjrEmBeTSSAnJ4ei\noiJKS0sjHUqzO/BkMZF4V7xzL7f/eS4LisrJymjJv43oyWVDu3FKz3YJdfLX1GIyCaSkpOjJWiJx\n7P2VpXx38qdU1zpPjD2ZLw/pSnJSzD7+JKrFZBIQkfhUV+c89U4hv5q5kn6d2vD010+hd3ZGpMOK\na0oCIhIVKvfXcNcL85m5bAtXnNyNX1w1hFap+ohqavoNi0jEbavYxy2TClhYtJOfXDaQG8/IVbt/\nM1ESEJGI2rCtkhufm0PJzr387uvDuXBQw7PuSvgoCYhIxCwuLmf8c59QU1fHX249jeG9OkQ6pISj\nJCAiEbFyy27GTphF2/QUJt98WlincZbGUxIQkWa3q6qab/1pLumpSbz47dPp2jY90iElLCUBEWlW\n7s6/T1nA+u2VvHDrSCWACNPdFyLSrH733hreWrqF+y49kRF56gOINCUBEWk2HxaW8cj05XzlpK7c\nfGZupMMRlAREpJlsKt/LnS98ygnZGTx09Um6DyBKqE9ARJrFg68vo3J/DVO+eTqtW+qjJ1roSkBE\nmtzc9Tt4beEmbjv7BPp00lxA0URJQESalLvz89eXkt2mJd88u3ekw5GDKAmISJN6beEmPt2wkx9e\n2F/NQFFISUBEmkxVdS0PvbmcAV3acPVwPQwpGikJiEiTmfjROop27OXHXx5IUguNBopGSgIi0iS2\nVezjN/8o5NwBnRjVNyvS4chhKAmISJN44u1VVFbXct+lAyIdihxBg0nAzNLMbI6ZLTCzJWb206D8\nETNbbmYLzewVM2tXb59
"text/plain": [
"<matplotlib.figure.Figure at 0x2ae07d12860>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"houses.plot()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.1"
}
},
"nbformat": 4,
"nbformat_minor": 2
}