Skip to content

Instantly share code, notes, and snippets.

@memonkey01
Created April 6, 2019 02:37
Show Gist options
  • Save memonkey01/ba8223c3dd1db9ed3fa807ba199a3854 to your computer and use it in GitHub Desktop.
Save memonkey01/ba8223c3dd1db9ed3fa807ba199a3854 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"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>ds</th>\n",
" <th>y</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>2010-08-18</td>\n",
" <td>0.074000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>2010-08-20</td>\n",
" <td>0.066700</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>2010-08-22</td>\n",
" <td>0.066400</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>2010-08-24</td>\n",
" <td>0.066889</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>2010-08-26</td>\n",
" <td>0.066499</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" ds y\n",
"0 2010-08-18 0.074000\n",
"1 2010-08-20 0.066700\n",
"2 2010-08-22 0.066400\n",
"3 2010-08-24 0.066889\n",
"4 2010-08-26 0.066499"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"#File created to download Bitcoin stas from Blockchain.info\n",
"import numpy as np\n",
"import requests\n",
"import json\n",
"import pandas as pd\n",
"import matplotlib\n",
"import matplotlib.pyplot as plt\n",
"from pandas.io.json import json_normalize\n",
"import matplotlib.mlab as mlab\n",
"import matplotlib.ticker as mtick\n",
"\n",
"matplotlib.style.use('dark_background')\n",
"\n",
"#Get prices from blockchain.info\n",
"priceraw = 'https://api.blockchain.info/charts/market-price?timespan=all&format=json'\n",
"response = requests.get(priceraw)\n",
"jasonvar = json.loads(response.content)\n",
"#Working the request into a DataFrame\n",
"prices = pd.io.json.json_normalize(jasonvar['values'])\n",
"prices['x'] = pd.to_datetime(prices['x'], unit='s')\n",
"prices = prices.set_index('x')\n",
"prices = prices[(prices.T != 0).any()]\n",
"\n",
"prices['ds'] = prices.index\n",
"prices = prices[['ds','y']].reset_index()\n",
"prices = prices[['ds','y']]\n",
"prices.head()"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"ename": "ModuleNotFoundError",
"evalue": "No module named 'fbprophet'",
"output_type": "error",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)",
"\u001b[1;32m<ipython-input-4-3dac74d0cfd4>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[1;32mfrom\u001b[0m \u001b[0mfbprophet\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mProphet\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[1;31mModuleNotFoundError\u001b[0m: No module named 'fbprophet'"
]
}
],
"source": [
"from fbprophet import Prophet"
]
},
{
"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.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment