Created
February 14, 2017 05:14
-
-
Save inoccu/bcdfebf1197604e62697a67ce82a8c8b 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
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"outputs": [], | |
"metadata": { | |
"collapsed": true | |
}, | |
"source": "# The code was removed by DSX for sharing.", | |
"execution_count": 1 | |
}, | |
{ | |
"cell_type": "code", | |
"outputs": [ | |
{ | |
"text": "Collecting cloudant\n Downloading cloudant-2.3.1.tar.gz (48kB)\n\u001b[K 100% |\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588| 51kB 2.7MB/s \n\u001b[?25hRequirement already satisfied (use --upgrade to upgrade): requests<3.0.0,>=2.7.0 in /usr/local/src/conda3_runtime.v4/4.1.1/lib/python3.5/site-packages (from cloudant)\nBuilding wheels for collected packages: cloudant\n Running setup.py bdist_wheel for cloudant ... \u001b[?25l-\b \b\\\b \bdone\n\u001b[?25h Stored in directory: /gpfs/fs01/user/sbcf-fd41f5fdd05671-30a815acdc92/.cache/pip/wheels/40/93/a6/d9913de4cbec6ea134416d49fabedff7899376100a620ad6f7\nSuccessfully built cloudant\nInstalling collected packages: cloudant\nSuccessfully installed cloudant-2.3.1\n", | |
"output_type": "stream", | |
"name": "stdout" | |
} | |
], | |
"metadata": { | |
"scrolled": true, | |
"collapsed": false | |
}, | |
"source": "!pip install --user cloudant", | |
"execution_count": 3 | |
}, | |
{ | |
"cell_type": "code", | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"data": { | |
"text/plain": "['_replicator', '_users', '_warehouser', 'nodered', 'sakura_iot']" | |
}, | |
"metadata": {}, | |
"execution_count": 9 | |
} | |
], | |
"metadata": { | |
"collapsed": false | |
}, | |
"source": "from cloudant.client import Cloudant\nfrom cloudant.result import Result\n\nclient = Cloudant(credentials_1[\"username\"], credentials_1[\"password\"], url=credentials_1[\"url\"])\nclient.connect()\nclient.all_dbs()", | |
"execution_count": 9 | |
}, | |
{ | |
"cell_type": "code", | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"data": { | |
"text/plain": " _id _rev \\\n0 01bbc09c49c51ca2af1c2f0077beba1c 1-c2c566f48808c07480ea5dfcc43aa094 \n1 01bbc09c49c51ca2af1c2f0077eb709a 1-8349dcf6ff522970582dcaee397c79a5 \n2 0f31258932e7aafcb9e590e2792c1a73 1-e9d93e0459e4e53385259a215f94e227 \n3 0f31258932e7aafcb9e590e27957193c 1-132eff6caf6b3e7151a36ef63c28d814 \n4 0f31258932e7aafcb9e590e27971db80 1-4901832867318a17569247b3e5a7fd7c \n\n datetime light module temperature \n0 2017-02-14T04:36:57.140104706Z 413 ujCvrJMT5MhW 1.524994 \n1 2017-02-14T04:41:13.952045814Z 401 ujCvrJMT5MhW 0.710113 \n2 2017-02-14T04:48:01.817835267Z 400 ujCvrJMT5MhW 0.607300 \n3 2017-02-14T04:51:03.091761397Z 413 ujCvrJMT5MhW 0.710113 \n4 2017-02-14T04:54:04.378442787Z 412 ujCvrJMT5MhW 1.322510 ", | |
"text/html": "<div>\n<table border=\"1\" class=\"dataframe\">\n <thead>\n <tr style=\"text-align: right;\">\n <th></th>\n <th>_id</th>\n <th>_rev</th>\n <th>datetime</th>\n <th>light</th>\n <th>module</th>\n <th>temperature</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <th>0</th>\n <td>01bbc09c49c51ca2af1c2f0077beba1c</td>\n <td>1-c2c566f48808c07480ea5dfcc43aa094</td>\n <td>2017-02-14T04:36:57.140104706Z</td>\n <td>413</td>\n <td>ujCvrJMT5MhW</td>\n <td>1.524994</td>\n </tr>\n <tr>\n <th>1</th>\n <td>01bbc09c49c51ca2af1c2f0077eb709a</td>\n <td>1-8349dcf6ff522970582dcaee397c79a5</td>\n <td>2017-02-14T04:41:13.952045814Z</td>\n <td>401</td>\n <td>ujCvrJMT5MhW</td>\n <td>0.710113</td>\n </tr>\n <tr>\n <th>2</th>\n <td>0f31258932e7aafcb9e590e2792c1a73</td>\n <td>1-e9d93e0459e4e53385259a215f94e227</td>\n <td>2017-02-14T04:48:01.817835267Z</td>\n <td>400</td>\n <td>ujCvrJMT5MhW</td>\n <td>0.607300</td>\n </tr>\n <tr>\n <th>3</th>\n <td>0f31258932e7aafcb9e590e27957193c</td>\n <td>1-132eff6caf6b3e7151a36ef63c28d814</td>\n <td>2017-02-14T04:51:03.091761397Z</td>\n <td>413</td>\n <td>ujCvrJMT5MhW</td>\n <td>0.710113</td>\n </tr>\n <tr>\n <th>4</th>\n <td>0f31258932e7aafcb9e590e27971db80</td>\n <td>1-4901832867318a17569247b3e5a7fd7c</td>\n <td>2017-02-14T04:54:04.378442787Z</td>\n <td>412</td>\n <td>ujCvrJMT5MhW</td>\n <td>1.322510</td>\n </tr>\n </tbody>\n</table>\n</div>" | |
}, | |
"metadata": {}, | |
"execution_count": 10 | |
} | |
], | |
"metadata": { | |
"collapsed": false | |
}, | |
"source": "import pandas as pd, json\n\ndb = client['sakura_iot']\nresult_collection = Result(db.all_docs, include_docs=True)\ndf = pd.DataFrame([item['doc'] for item in result_collection])\ndf.head()", | |
"execution_count": 10 | |
}, | |
{ | |
"cell_type": "code", | |
"outputs": [], | |
"metadata": { | |
"collapsed": true | |
}, | |
"source": "", | |
"execution_count": null | |
} | |
], | |
"nbformat": 4, | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 3.5 (Experimental) with Spark 1.6", | |
"name": "python3", | |
"language": "python" | |
}, | |
"language_info": { | |
"mimetype": "text/x-python", | |
"version": "3.5.2", | |
"file_extension": ".py", | |
"name": "python", | |
"pygments_lexer": "ipython3", | |
"nbconvert_exporter": "python", | |
"codemirror_mode": { | |
"version": 3, | |
"name": "ipython" | |
} | |
} | |
}, | |
"nbformat_minor": 0 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment