People love to hate @ProjectJupyter notebooks!

They're missing out on a great communication tool.

Here's how data scientists and machine learners can
build great Jupyter Notebooks that people love to read

👇 🧵
🧮 Fix your dang code

You can make a mess in notebooks when experimenting.

1️⃣All Imports into Cell 1
2️⃣Extract some functions and classes
3️⃣Comments.
4️⃣Fix your variable names
5️⃣Fix the order and outputs
6️⃣Use black to standardize your code format https://github.com/drillan/jupyter-black
✒️ Jupyter has Markdown Cells!

Use them.
If you're not using Markdown in your Notebooks, you should not be using Notebooks.

Write some prose to explain your code.
Whether analysis or model,
do yourself a favour and document it.

Here's a markdown guide: https://www.markdownguide.org/getting-started/
🔂 Final checks

We all do it.

We forget to run a cell and wonder for an embarrassing amount of time, why we have an error in the next one.

Before you share your notebook:
1️⃣Restart Kernel to forget all variables
2️⃣Run All Cells

Not by hand. Automatic.
It'll show any mix-ups
If this thread was informative
make sure to follow @jesperdramsch

and share the first tweet ☝ for others to learn!

I am writing 30 threads in 30 days about

🧵 machine learning
🧵 data science
🧵 Python coding

Find them here: https://twitter.com/JesperDramsch/status/1479863422967767040
🏆 Extra Credit

🦾 Use nbconvert to run all cells from the command line

🧠 Write a utils file with reusable functions

⌨ Learn keyboard shortcuts for efficiency

🎨 Make it interactive with ipykernel
TL;DR

👉 Care about code quality
👉 Use markdown cells (More than just headings)
👉 Make sure the notebook runs
👉 Use extra tools to make your life easier
You can follow @JesperDramsch.
Tip: mention @twtextapp on a Twitter thread with the keyword “unroll” to get a link to it.

Latest Threads Unrolled: