280 lines
7.7 KiB
Plaintext
280 lines
7.7 KiB
Plaintext
|
{
|
|||
|
"cells": [
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"# Pandas Datareader\n",
|
|||
|
"\n",
|
|||
|
"**EMARQUE : Tous les emplacements géographiques ne fonctionnent pas bien avec le lecteur de données pandas, votre pare-feu peut aussi le bloquer !**\n",
|
|||
|
"\n",
|
|||
|
"Les fonctions de pandas_datareader.data et pandas_datareader.wb extraient les données de diverses sources Internet dans un DataFrame pandas. Actuellement, les sources suivantes sont supportées :\n",
|
|||
|
"\n",
|
|||
|
"* Yahoo! Finance\n",
|
|||
|
"* Enigma\n",
|
|||
|
"* St.Louis FED (FRED)\n",
|
|||
|
"* Kenneth French’s data library\n",
|
|||
|
"* World Bank\n",
|
|||
|
"* OECD\n",
|
|||
|
"* Eurostat\n",
|
|||
|
"* Thrift Savings Plan\n",
|
|||
|
"* Oanda currency historical rate\n",
|
|||
|
"* Nasdaq Trader symbol definitions (remote_data.nasdaq_symbols)\n",
|
|||
|
"\n",
|
|||
|
"Il convient de noter que diverses sources soutiennent différents types de données, de sorte que toutes les sources n'appliquent pas les mêmes méthodes et que les éléments de données retournés peuvent également différer."
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 1,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [],
|
|||
|
"source": [
|
|||
|
"import pandas_datareader.data as web\n",
|
|||
|
"\n",
|
|||
|
"import datetime\n",
|
|||
|
"\n",
|
|||
|
"start = datetime.datetime(2015, 1, 1)\n",
|
|||
|
"\n",
|
|||
|
"end = datetime.datetime(2017, 1, 1)\n",
|
|||
|
"\n",
|
|||
|
"facebook = web.DataReader(\"FB\", 'yahoo', start, end)"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 2,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"text/html": [
|
|||
|
"<div>\n",
|
|||
|
"<style scoped>\n",
|
|||
|
" .dataframe tbody tr th:only-of-type {\n",
|
|||
|
" vertical-align: middle;\n",
|
|||
|
" }\n",
|
|||
|
"\n",
|
|||
|
" .dataframe tbody tr th {\n",
|
|||
|
" vertical-align: top;\n",
|
|||
|
" }\n",
|
|||
|
"\n",
|
|||
|
" .dataframe thead th {\n",
|
|||
|
" text-align: right;\n",
|
|||
|
" }\n",
|
|||
|
"</style>\n",
|
|||
|
"<table border=\"1\" class=\"dataframe\">\n",
|
|||
|
" <thead>\n",
|
|||
|
" <tr style=\"text-align: right;\">\n",
|
|||
|
" <th></th>\n",
|
|||
|
" <th>High</th>\n",
|
|||
|
" <th>Low</th>\n",
|
|||
|
" <th>Open</th>\n",
|
|||
|
" <th>Close</th>\n",
|
|||
|
" <th>Volume</th>\n",
|
|||
|
" <th>Adj Close</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",
|
|||
|
" </tr>\n",
|
|||
|
" </thead>\n",
|
|||
|
" <tbody>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>2015-01-02</th>\n",
|
|||
|
" <td>78.930000</td>\n",
|
|||
|
" <td>77.699997</td>\n",
|
|||
|
" <td>78.580002</td>\n",
|
|||
|
" <td>78.449997</td>\n",
|
|||
|
" <td>18177500</td>\n",
|
|||
|
" <td>78.449997</td>\n",
|
|||
|
" </tr>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>2015-01-05</th>\n",
|
|||
|
" <td>79.250000</td>\n",
|
|||
|
" <td>76.860001</td>\n",
|
|||
|
" <td>77.980003</td>\n",
|
|||
|
" <td>77.190002</td>\n",
|
|||
|
" <td>26452200</td>\n",
|
|||
|
" <td>77.190002</td>\n",
|
|||
|
" </tr>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>2015-01-06</th>\n",
|
|||
|
" <td>77.589996</td>\n",
|
|||
|
" <td>75.360001</td>\n",
|
|||
|
" <td>77.230003</td>\n",
|
|||
|
" <td>76.150002</td>\n",
|
|||
|
" <td>27399300</td>\n",
|
|||
|
" <td>76.150002</td>\n",
|
|||
|
" </tr>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>2015-01-07</th>\n",
|
|||
|
" <td>77.360001</td>\n",
|
|||
|
" <td>75.820000</td>\n",
|
|||
|
" <td>76.760002</td>\n",
|
|||
|
" <td>76.150002</td>\n",
|
|||
|
" <td>22045300</td>\n",
|
|||
|
" <td>76.150002</td>\n",
|
|||
|
" </tr>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>2015-01-08</th>\n",
|
|||
|
" <td>78.230003</td>\n",
|
|||
|
" <td>76.080002</td>\n",
|
|||
|
" <td>76.739998</td>\n",
|
|||
|
" <td>78.180000</td>\n",
|
|||
|
" <td>23961000</td>\n",
|
|||
|
" <td>78.180000</td>\n",
|
|||
|
" </tr>\n",
|
|||
|
" </tbody>\n",
|
|||
|
"</table>\n",
|
|||
|
"</div>"
|
|||
|
],
|
|||
|
"text/plain": [
|
|||
|
" High Low Open Close Volume Adj Close\n",
|
|||
|
"Date \n",
|
|||
|
"2015-01-02 78.930000 77.699997 78.580002 78.449997 18177500 78.449997\n",
|
|||
|
"2015-01-05 79.250000 76.860001 77.980003 77.190002 26452200 77.190002\n",
|
|||
|
"2015-01-06 77.589996 75.360001 77.230003 76.150002 27399300 76.150002\n",
|
|||
|
"2015-01-07 77.360001 75.820000 76.760002 76.150002 22045300 76.150002\n",
|
|||
|
"2015-01-08 78.230003 76.080002 76.739998 78.180000 23961000 78.180000"
|
|||
|
]
|
|||
|
},
|
|||
|
"execution_count": 2,
|
|||
|
"metadata": {},
|
|||
|
"output_type": "execute_result"
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"facebook.head()"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"# FRED"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 7,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [],
|
|||
|
"source": [
|
|||
|
"import pandas_datareader.data as web\n",
|
|||
|
"\n",
|
|||
|
"import datetime\n",
|
|||
|
"\n",
|
|||
|
"start = datetime.datetime(2010, 1, 1)\n",
|
|||
|
"\n",
|
|||
|
"end = datetime.datetime(2017, 1, 1)\n",
|
|||
|
"\n",
|
|||
|
"gdp = web.DataReader(\"GDP\", \"fred\", start, end)"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 8,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"text/html": [
|
|||
|
"<div>\n",
|
|||
|
"<style scoped>\n",
|
|||
|
" .dataframe tbody tr th:only-of-type {\n",
|
|||
|
" vertical-align: middle;\n",
|
|||
|
" }\n",
|
|||
|
"\n",
|
|||
|
" .dataframe tbody tr th {\n",
|
|||
|
" vertical-align: top;\n",
|
|||
|
" }\n",
|
|||
|
"\n",
|
|||
|
" .dataframe thead th {\n",
|
|||
|
" text-align: right;\n",
|
|||
|
" }\n",
|
|||
|
"</style>\n",
|
|||
|
"<table border=\"1\" class=\"dataframe\">\n",
|
|||
|
" <thead>\n",
|
|||
|
" <tr style=\"text-align: right;\">\n",
|
|||
|
" <th></th>\n",
|
|||
|
" <th>GDP</th>\n",
|
|||
|
" </tr>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>DATE</th>\n",
|
|||
|
" <th></th>\n",
|
|||
|
" </tr>\n",
|
|||
|
" </thead>\n",
|
|||
|
" <tbody>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>2010-01-01</th>\n",
|
|||
|
" <td>14721.350</td>\n",
|
|||
|
" </tr>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>2010-04-01</th>\n",
|
|||
|
" <td>14926.098</td>\n",
|
|||
|
" </tr>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>2010-07-01</th>\n",
|
|||
|
" <td>15079.917</td>\n",
|
|||
|
" </tr>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>2010-10-01</th>\n",
|
|||
|
" <td>15240.843</td>\n",
|
|||
|
" </tr>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>2011-01-01</th>\n",
|
|||
|
" <td>15285.828</td>\n",
|
|||
|
" </tr>\n",
|
|||
|
" </tbody>\n",
|
|||
|
"</table>\n",
|
|||
|
"</div>"
|
|||
|
],
|
|||
|
"text/plain": [
|
|||
|
" GDP\n",
|
|||
|
"DATE \n",
|
|||
|
"2010-01-01 14721.350\n",
|
|||
|
"2010-04-01 14926.098\n",
|
|||
|
"2010-07-01 15079.917\n",
|
|||
|
"2010-10-01 15240.843\n",
|
|||
|
"2011-01-01 15285.828"
|
|||
|
]
|
|||
|
},
|
|||
|
"execution_count": 8,
|
|||
|
"metadata": {},
|
|||
|
"output_type": "execute_result"
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"gdp.head()"
|
|||
|
]
|
|||
|
}
|
|||
|
],
|
|||
|
"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.7.5"
|
|||
|
}
|
|||
|
},
|
|||
|
"nbformat": 4,
|
|||
|
"nbformat_minor": 2
|
|||
|
}
|