create account

[Python Tips] Jupyter Notebooks by themarkymark

View this thread on: hive.blogpeakd.comecency.com
· @themarkymark · (edited)
$173.11
[Python Tips] Jupyter Notebooks
![](https://steemitimages.com/DQmSsFP8BDE1DkXNN9hh1729MRexyqupLEKfWJTsRskjt33/image.png) 

This is probably my favorite tip to offer.  If you haven't heard of Jupyter Notebooks, this is going to be a huge game changer for you.

https://i.imgur.com/dNyWSng.png
<sub>[Source](http://jupyter.org/)</sub>

While I only use Jupyter Notebooks with Python, I know it can be used with lots of languages and frameworks.  I only have experience using it for Python and Machine Learning.

Jupyter Notebooks is different than anything I have ever seen before, the closest thing I describe it to is an interactive shell with charting, visualization, interactive widgets, reporting, and so much more.  

Python is frequently used for data analysis and machine learning, in this capacity you are frequently working with large datasets and visualization.

You might be doing something where you have a simple dataset where you want to chart it.

![](https://steemitimages.com/DQmXMDTJQDq3o3Z71N7CZtt8EnpKecf9vb4YesoWAjviQp2/image.png)
<sub>[Source](https://danieltakeshi.github.io/2016-01-16-ipython-jupyter-notebooks-and-matplotlib/)</sub>

To something far more complicated involving interactive charting and complex math.

![](https://steemitimages.com/DQmSwxWo31xpyt4KadVJ5KvC1kFP7pNV2oddWWSvYL75LQu/image.png)
<sub>[Source](http://jupyter.org/)</sub>

![](https://steemitimages.com/DQmdbpKSh86hthTg8a6JV98UASimZF7GAkS9yxKekSXfbgd/image.png)
<sub>[Source](http://arogozhnikov.github.io/2016/09/10/jupyter-features.html)</sub>

I am not going to go to in depth as this is more to introduce you to the fact that Jupyter Notebooks exists and what it can do.  To cover how to use it would be far more than I can do in a single post.

One use for Jupyter Notebooks that isn't talked about a lot is when you are testing out code and working with an API and want to have instant feedback.  One of the nice things is you can run each block individually, so you can run your import block and setup code, then mess around with your experimental code re-running it as needed as you test things out.  

If you have to import a new module, just add it to the import block and re-run that block or the entire notebook.

Let's take a simple Steem example:

https://i.imgur.com/nRsZSBw.png

Now we decide we want to do something with datetime, we can easily update the top block to have `import datetime` and re-run just that part.

https://i.imgur.com/Ab6Pf95.png

We don't have to re-run the entire script if we don't want to.  If you break your scripts into chunks and put them into different cells, it becomes easy to change parts of your code and re-run only what you need.

I don't recommend using Notebooks for everything, but there is a lot of code I run that is more of reporting and data collection on the blockchain and it is far easier to do this in a Jupyter Notebook than command line or an IDE.

When working with lots of data you want to graph and see visually, Jupyter Notebooks cannot be beaten.

If you use Anaconda for your Python distribution (**highly recommended**) you don't need to do anything to install Jupyter Notebooks, you already have it.  Just type `jupyter notebook` from a command line and it will start running.

There is a newer version of Jupyter Notebook called Jupyter Lab which is in development and beta.  It has some additional features like tabs, text editor support, data file viewers, and some new components that makes it much more powerful.  It is also fully compatible with Jupyter Notebook files.  I suggest using Jupyter Notebooks first, and testing Lab when you are familiar with Notebook.

# Sharing

One of the best things about Jupyter Notebooks is the ability to share Notebooks with other people and easily export them into PDF format for those who don't have Python installed.

Github also has full support for Notebooks, if there are notebooks in your repo, you can just view them online without having anything installed.  Very cool.

# Examples

There are lots of examples you can look at on Jupyter's website under the [nbviewer](https://nbviewer.jupyter.org/).  One of the great things about Jupyter Notebooks is you can mix Markdown with Code and create really great reports and data visualization that can be shared easily.  The end user can view the notebook as a PDF, HTML file, or even as a Notebook they can run and edit themselves.


# My Python Tips Series
* [f-strings in Python 3.6](https://steemit.com/programming/@themarkymark/python-tips-f-strings-in-python-3-6-and-why-you-should-be-using-them)
* [Underscores in numeric literals](https://steemit.com/programming/@themarkymark/python-tips-underscores-in-numeric-literals)
* [A better interactive shell](https://steemit.com/programming/@themarkymark/python-tips-a-better-interactive-shell)
* [Secrets Module - New in 3.6](https://steemit.com/programming/@themarkymark/python-tips-secrets-module-new-in-3-6)
* [PEP 8](https://steemit.com/programming/@themarkymark/python-tips-pep-8)
* [Slices](https://steemit.com/programming/@themarkymark/python-tips-slices)
* [Named Tuples](https://steemit.com/programming/@themarkymark/python-tips-named-tuples)
* [Destructuring](https://steemit.com/programming/@themarkymark/python-tips-destructuring)
* [Counter](https://steemit.com/programming/@themarkymark/python-tips-counter)
* [Type Annotation](https://steemit.com/programming/@themarkymark/python-tips-type-annotation)
πŸ‘  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 154 others
πŸ‘Ž  
properties (23)
authorthemarkymark
permlinkpython-tips-jupyter-notebooks
categoryprogramming
json_metadata{"tags":["programming","python","python-tips","dev","tutorial"],"image":["https://steemitimages.com/DQmSsFP8BDE1DkXNN9hh1729MRexyqupLEKfWJTsRskjt33/image.png","https://i.imgur.com/dNyWSng.png","https://steemitimages.com/DQmXMDTJQDq3o3Z71N7CZtt8EnpKecf9vb4YesoWAjviQp2/image.png","https://steemitimages.com/DQmSwxWo31xpyt4KadVJ5KvC1kFP7pNV2oddWWSvYL75LQu/image.png","https://steemitimages.com/DQmdbpKSh86hthTg8a6JV98UASimZF7GAkS9yxKekSXfbgd/image.png","https://i.imgur.com/nRsZSBw.png","https://i.imgur.com/Ab6Pf95.png"],"links":["http://jupyter.org/","https://danieltakeshi.github.io/2016-01-16-ipython-jupyter-notebooks-and-matplotlib/","http://arogozhnikov.github.io/2016/09/10/jupyter-features.html","https://nbviewer.jupyter.org/","https://steemit.com/programming/@themarkymark/python-tips-f-strings-in-python-3-6-and-why-you-should-be-using-them","https://steemit.com/programming/@themarkymark/python-tips-underscores-in-numeric-literals","https://steemit.com/programming/@themarkymark/python-tips-a-better-interactive-shell","https://steemit.com/programming/@themarkymark/python-tips-secrets-module-new-in-3-6","https://steemit.com/programming/@themarkymark/python-tips-pep-8","https://steemit.com/programming/@themarkymark/python-tips-slices","https://steemit.com/programming/@themarkymark/python-tips-named-tuples","https://steemit.com/programming/@themarkymark/python-tips-destructuring","https://steemit.com/programming/@themarkymark/python-tips-counter","https://steemit.com/programming/@themarkymark/python-tips-type-annotation"],"app":"steemit/0.1","format":"markdown"}
created2018-05-10 01:36:33
last_update2018-05-10 01:43:36
depth0
children15
last_payout2018-05-17 01:36:33
cashout_time1969-12-31 23:59:59
total_payout_value152.030 HBD
curator_payout_value21.081 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length5,409
author_reputation1,783,341,958,946,978
root_title"[Python Tips] Jupyter Notebooks"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id54,858,479
net_rshares35,518,261,552,020
author_curate_reward""
vote details (219)
@abdul1234 ·
This is my first time of hearing about it and I really appreciate your efforts, am gonna get it
properties (22)
authorabdul1234
permlinkre-themarkymark-python-tips-jupyter-notebooks-20180510t020459495z
categoryprogramming
json_metadata{"tags":["programming"],"app":"steemit/0.1"}
created2018-05-10 02:06:30
last_update2018-05-10 02:06:30
depth1
children0
last_payout2018-05-17 02:06:30
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length95
author_reputation122,942,691,090
root_title"[Python Tips] Jupyter Notebooks"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id54,862,816
net_rshares0
@aril.hatake ·
snake game that I like most in my childhood .. until now I am still a favorite game .. I really like your post ...
properties (22)
authoraril.hatake
permlinkre-themarkymark-2018510t922316z
categoryprogramming
json_metadata{"tags":["programming","python","python-tips","dev","tutorial"],"app":"esteem/1.5.1","format":"markdown+html","community":"esteem"}
created2018-05-10 02:22:33
last_update2018-05-10 02:22:33
depth1
children0
last_payout2018-05-17 02:22:33
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length114
author_reputation2,074,878,176,867
root_title"[Python Tips] Jupyter Notebooks"
beneficiaries
0.
accountesteemapp
weight1,000
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id54,865,226
net_rshares0
@epearson ·
Jupyter notebooks are great. I actually run notebooks in [Docker](https://hub.docker.com/r/jupyter/datascience-notebook/). I've ran into problem with python running on my Mac. Docker made life easier. 
properties (22)
authorepearson
permlinkre-themarkymark-python-tips-jupyter-notebooks-20180512t004229365z
categoryprogramming
json_metadata{"tags":["programming"],"community":"busy","app":"busy/2.4.0"}
created2018-05-12 00:42:30
last_update2018-05-12 00:42:30
depth1
children1
last_payout2018-05-19 00:42:30
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length201
author_reputation3,916,382,738,122
root_title"[Python Tips] Jupyter Notebooks"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id55,207,435
net_rshares0
@themarkymark ·
Python already has a solution for that.  Virtual Environments.   β€˜Virtualenv’
properties (22)
authorthemarkymark
permlinkre-epearson-re-themarkymark-python-tips-jupyter-notebooks-20180512t013446892z
categoryprogramming
json_metadata{"tags":["programming"],"app":"steemit/0.1"}
created2018-05-12 01:34:48
last_update2018-05-12 01:34:48
depth2
children0
last_payout2018-05-19 01:34:48
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length77
author_reputation1,783,341,958,946,978
root_title"[Python Tips] Jupyter Notebooks"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id55,212,942
net_rshares0
@makerhacks ·
$0.04
Mixing in the markdown with the code is intruiging. I don’t do much statistical stuff but I’m still thinking I should try it out :)
πŸ‘  
properties (23)
authormakerhacks
permlinkre-themarkymark-python-tips-jupyter-notebooks-20180510t014032503z
categoryprogramming
json_metadata{"tags":["programming"],"app":"steemit/0.1"}
created2018-05-10 01:40:33
last_update2018-05-10 01:40:33
depth1
children1
last_payout2018-05-17 01:40:33
cashout_time1969-12-31 23:59:59
total_payout_value0.030 HBD
curator_payout_value0.009 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length131
author_reputation157,733,918,636,411
root_title"[Python Tips] Jupyter Notebooks"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id54,859,026
net_rshares8,552,569,374
author_curate_reward""
vote details (1)
@themarkymark · (edited)
The markdown is good for describing what is going on.  If you look at some of the example notebooks, they do a good show showing how it can help.

For example, this simple notebook uses it to give an overview of each code block and what's going on.  Most of the time when using Notebooks you are dealing with a lot of data.

https://i.imgur.com/oo9mmGh.png

Another great example:

https://www.kaggle.com/stkbailey/teaching-notebook-for-total-imaging-newbies
properties (22)
authorthemarkymark
permlinkre-makerhacks-re-themarkymark-python-tips-jupyter-notebooks-20180510t014340083z
categoryprogramming
json_metadata{"tags":["programming"],"image":["https://i.imgur.com/oo9mmGh.png"],"app":"steemit/0.1","links":["https://www.kaggle.com/stkbailey/teaching-notebook-for-total-imaging-newbies"]}
created2018-05-10 01:43:03
last_update2018-05-10 01:45:42
depth2
children0
last_payout2018-05-17 01:43:03
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length458
author_reputation1,783,341,958,946,978
root_title"[Python Tips] Jupyter Notebooks"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id54,859,379
net_rshares0
@nicnas · (edited)
$0.04
You showing me this a couple months ago has been a game changer for how I interact with python and my server. For troubleshooting and learning it has been a god send. Really do appreciate your help getting started.
πŸ‘  ,
properties (23)
authornicnas
permlinkre-themarkymark-python-tips-jupyter-notebooks-20180510t040359005z
categoryprogramming
json_metadata{"tags":["programming"],"app":"steemit/0.1"}
created2018-05-10 04:04:00
last_update2018-05-10 04:04:54
depth1
children0
last_payout2018-05-17 04:04:00
cashout_time1969-12-31 23:59:59
total_payout_value0.036 HBD
curator_payout_value0.006 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length214
author_reputation38,554,121,369,241
root_title"[Python Tips] Jupyter Notebooks"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id54,878,151
net_rshares9,160,113,822
author_curate_reward""
vote details (2)
@qurator-tier-0 ·
<div class="pull-left"><img src="![Qsmall.png](https://steemitimages.com/DQmcWoZUnPrRW1UdZeVPWhHpnXfkgWAdFHGxMrSgZoxSZw8/Qsmall.png)" /></div>
		
<center>You just received a Tier 0 upvote!  Looking for bigger rewards? Click [here](https://steemit.com/qurator/@qurator/qurator-tier-changes) and learn how to get them or visit us on [Discord](https://discord.gg/nhQehdv)</center>
properties (22)
authorqurator-tier-0
permlinkre-python-tips-jupyter-notebooks-20180510t082132
categoryprogramming
json_metadata""
created2018-05-10 08:21:33
last_update2018-05-10 08:21:33
depth1
children0
last_payout2018-05-17 08:21:33
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length377
author_reputation59,310,010,441
root_title"[Python Tips] Jupyter Notebooks"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id54,911,395
net_rshares0
@skorpsim ·
$0.04
Jupyter Notebook is just awesome! 
I was introduced to it by a colleague. We used MATLAB and struggled to get a licence because of a shortage. He already used IPython Notebook and at the time it upgraded to Jupyter Notebook he set up a server and  introduced his subdivision colleagues. It spread like a wildfire in the whole R&D department. I have never seen a similar adoption and success of an open source tool or any other tool. 

This experience was a game changer for me and I started using more open source software like LATEX, Blender and Inkscape. Brave Browser is the latest member of this club.

Jupyter Notebook is best used on Linux. In case you want to try it on Windows i recommend [WinPython](https://sourceforge.net/projects/winpython/), it contains Jupyter Notebook beside some other useful tool-sets.

Even Microsoft is in love with Jupyter Notebooks! You can use them for FREE on [Azure Notebooks](https://notebooks.azure.com/). Microsoft uses a Linux server environment and Python 2.X, 3.X, R and F# Kernels are pre-installed.
πŸ‘  
properties (23)
authorskorpsim
permlinkre-themarkymark-python-tips-jupyter-notebooks-20180510t073822444z
categoryprogramming
json_metadata{"tags":["programming"],"links":["https://sourceforge.net/projects/winpython/","https://notebooks.azure.com/"],"app":"steemit/0.1"}
created2018-05-10 07:38:21
last_update2018-05-10 07:38:21
depth1
children1
last_payout2018-05-17 07:38:21
cashout_time1969-12-31 23:59:59
total_payout_value0.030 HBD
curator_payout_value0.009 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length1,047
author_reputation25,717,868,956
root_title"[Python Tips] Jupyter Notebooks"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id54,905,612
net_rshares8,552,569,374
author_curate_reward""
vote details (1)
@themarkymark ·
Check out Jupyter Lab the next iteration of Notebooks.
πŸ‘  
properties (23)
authorthemarkymark
permlinkre-skorpsim-re-themarkymark-python-tips-jupyter-notebooks-20180510t122704886z
categoryprogramming
json_metadata{"tags":["programming"],"app":"steemit/0.1"}
created2018-05-10 12:27:03
last_update2018-05-10 12:27:03
depth2
children0
last_payout2018-05-17 12:27:03
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length54
author_reputation1,783,341,958,946,978
root_title"[Python Tips] Jupyter Notebooks"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id54,946,486
net_rshares592,202,416
author_curate_reward""
vote details (1)
@stabilowl ·
$0.04
Notebooks are great for tutorials and courses.  I was doing a course on deep learning on Coursera and the tutorials/homeworks were Notebooks. I have used Notebooks for Kaggle submissions as well. 

I am a bit confused though in terms of the difference between Jupyter Notebook and IPython Notebook,  so much so that I can't remember which was the one that I used...
πŸ‘  
properties (23)
authorstabilowl
permlinkre-themarkymark-python-tips-jupyter-notebooks-20180510t021946353z
categoryprogramming
json_metadata{"tags":["programming"],"app":"steemit/0.1"}
created2018-05-10 02:19:45
last_update2018-05-10 02:19:45
depth1
children1
last_payout2018-05-17 02:19:45
cashout_time1969-12-31 23:59:59
total_payout_value0.030 HBD
curator_payout_value0.009 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length365
author_reputation17,959,675,189,416
root_title"[Python Tips] Jupyter Notebooks"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id54,864,821
net_rshares8,552,569,374
author_curate_reward""
vote details (1)
@themarkymark ·
Jupyter is the new name, it used to be called Ipython Notebooks.
properties (22)
authorthemarkymark
permlinkre-stabilowl-re-themarkymark-python-tips-jupyter-notebooks-20180510t122608684z
categoryprogramming
json_metadata{"tags":["programming"],"app":"steemit/0.1"}
created2018-05-10 12:26:09
last_update2018-05-10 12:26:09
depth2
children0
last_payout2018-05-17 12:26:09
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length64
author_reputation1,783,341,958,946,978
root_title"[Python Tips] Jupyter Notebooks"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id54,946,342
net_rshares0
@steemcurrency ·
Jupyter Notebook is just awesome!
properties (22)
authorsteemcurrency
permlinkre-themarkymark-python-tips-jupyter-notebooks-20180515t090834498z
categoryprogramming
json_metadata{"tags":["programming"],"app":"steemit/0.1"}
created2018-05-15 09:08:36
last_update2018-05-15 09:08:36
depth1
children0
last_payout2018-05-22 09:08:36
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length33
author_reputation169,776,428,360
root_title"[Python Tips] Jupyter Notebooks"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id55,790,491
net_rshares0
@superoo7 ·
Github also have support for jupyter notebook, some hard core python coder will use it to document haha
properties (22)
authorsuperoo7
permlinkre-themarkymark-python-tips-jupyter-notebooks-20180510t020746250z
categoryprogramming
json_metadata{"tags":["programming"],"app":"steemit/0.1"}
created2018-05-10 02:07:39
last_update2018-05-10 02:07:39
depth1
children0
last_payout2018-05-17 02:07:39
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length103
author_reputation27,763,618,634,121
root_title"[Python Tips] Jupyter Notebooks"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id54,862,983
net_rshares0
@transparencybot ·
<h3>This post has received votes totaling more than $50.00 from the following pay for vote services:</h3>

minnowbooster upvote in the amount of $103.68 STU, $200.56 USD.

**For a total calculated value of $104 [STU,](http://steem.supply/rewards) $201 USD before curation, with approx. $26 USD curation being earned by the paid voters.**

This information is being presented in the interest of transparency on our platform **and is by no means a judgement as to the quality of this post.**
properties (22)
authortransparencybot
permlinkre-python-tips-jupyter-notebooks--bidbot
categoryprogramming
json_metadata{"tags":["bidbot","transparencybot"],"links":["http://steem.supply/rewards"],"app":"null/null","format":"markdown"}
created2018-05-10 02:02:33
last_update2018-05-10 02:02:33
depth1
children0
last_payout2018-05-17 02:02:33
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length495
author_reputation-5,641,716,862,244
root_title"[Python Tips] Jupyter Notebooks"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id54,862,233
net_rshares0