Last active
August 29, 2015 14:22
-
-
Save allthesignals/f279cc8d7ad2d52e9a35 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": [ | |
{ | |
"metadata": {}, | |
"cell_type": "markdown", | |
"source": "#Referencing Variables in Markdown" | |
}, | |
{ | |
"metadata": {}, | |
"cell_type": "markdown", | |
"source": "Import the extension in Javascript" | |
}, | |
{ | |
"metadata": { | |
"collapsed": false, | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "import IPython\nIPython.html.nbextensions.install_nbextension('https://raw.githubusercontent.com/ipython-contrib/IPython-notebook-extensions/3.x/usability/python-markdown/main.js')", | |
"execution_count": 31, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"text": "downloading https://raw.githubusercontent.com/ipython-contrib/IPython-notebook-extensions/3.x/usability/python-markdown/main.js to /tmp/tmpvxpksb6c/main.js\ncopying /tmp/tmpvxpksb6c/main.js -> /usr/local/share/jupyter/nbextensions/main.js\n", | |
"name": "stdout" | |
} | |
] | |
}, | |
{ | |
"metadata": {}, | |
"cell_type": "markdown", | |
"source": "Load it into the Javascript" | |
}, | |
{ | |
"metadata": { | |
"collapsed": false, | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "%%javascript\nIPython.load_extensions('main')", | |
"execution_count": 32, | |
"outputs": [ | |
{ | |
"output_type": "display_data", | |
"data": { | |
"application/javascript": "IPython.load_extensions('main')", | |
"text/plain": "<IPython.core.display.Javascript object>" | |
}, | |
"metadata": {} | |
} | |
] | |
}, | |
{ | |
"metadata": {}, | |
"cell_type": "markdown", | |
"source": "Create a variable and reference as \\{ \\{ test \\} \\} (No spaces!)" | |
}, | |
{ | |
"metadata": { | |
"collapsed": true, | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "a = 214 + 123424 + 1234234", | |
"execution_count": 33, | |
"outputs": [] | |
}, | |
{ | |
"metadata": { | |
"variables": { | |
"a": "1357872" | |
} | |
}, | |
"cell_type": "markdown", | |
"source": "THere are {{a}} in the Boston region who are this and that and so on. " | |
}, | |
{ | |
"metadata": { | |
"collapsed": false, | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "import pandas as pd\n\ndata = (12304 + 12345)/23\ndata", | |
"execution_count": 34, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"data": { | |
"text/plain": "1071.695652173913" | |
}, | |
"metadata": {}, | |
"execution_count": 34 | |
} | |
] | |
}, | |
{ | |
"metadata": { | |
"variables": { | |
"data": "1071.695652173913" | |
} | |
}, | |
"cell_type": "markdown", | |
"source": "I'm explaining that the amount of people in this area amount to {{data}} amount of etc." | |
}, | |
{ | |
"metadata": { | |
"trusted": true, | |
"collapsed": true | |
}, | |
"cell_type": "code", | |
"source": "my_analysis = 34 * 14 +13 / 24;\n", | |
"execution_count": 35, | |
"outputs": [] | |
}, | |
{ | |
"metadata": { | |
"variables": { | |
"my_analysis": "476.5416666666667" | |
} | |
}, | |
"cell_type": "markdown", | |
"source": "I found that my reuslt is {{my_analysis}}" | |
}, | |
{ | |
"metadata": { | |
"trusted": true, | |
"collapsed": false | |
}, | |
"cell_type": "code", | |
"source": "%%javascript\nIPython.load_extensions(\"gist\")", | |
"execution_count": 30, | |
"outputs": [ | |
{ | |
"output_type": "display_data", | |
"data": { | |
"application/javascript": "IPython.load_extensions(\"gist\")", | |
"text/plain": "<IPython.core.display.Javascript object>" | |
}, | |
"metadata": {} | |
} | |
] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"name": "python3", | |
"display_name": "Python 3", | |
"language": "python" | |
}, | |
"language_info": { | |
"mimetype": "text/x-python", | |
"pygments_lexer": "ipython3", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"version": "3.4.2", | |
"codemirror_mode": { | |
"version": 3, | |
"name": "ipython" | |
}, | |
"file_extension": ".py" | |
}, | |
"gist_id": "f279cc8d7ad2d52e9a35" | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 0 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment