Why I’m Making the Switch to marimo Notebooks

-

of using Jupyter Lab, I actually have moved most of my work to marimo notebooks, a brand new type of Python notebook that addresses many long-standing issues with traditional ones. This text covers the explanations behind my transition and the way marimo matches naturally into my current workflow, with full gratitude to Project Jupyter for constructing the notebook ecosystem that shaped data science, research and education.

A little bit of background

I actually have spent years inside notebooks. For a very long time, my setup was a mixture of Jupyter Notebooks/Lab for local experiments and Google Colab for cloud or GPU work, because of their free tier option. I actually have even authored many blogs on making essentially the most out of those notebooks, where I actually have shared tricks to transcend the conventional way of using them.

Having said that, there have been certain issues with these traditional notebooks, the most important being reactivity (or fairly, the shortage of it). Hidden state, out-of-order execution, and manual reruns were a few of my pain points with these notebooks.

That modified once I discovered marimo, an open-source alternative for Jupyter notebooks wherein you possibly can run cells, perform computations, and create plots just as you’ll in Jupyter. But underneath, it really works very in another way and fixes many long-standing issues. The important thing difference is that a marimo notebook is only a Python file, making it each a greater notebook and a greater coding environment for anyone who uses Python. In this text, I share ten reasons behind my switch and why working with notebooks has been much smoother for me since moving to marimo.

marimo.recent

pip install marimo
marimo edit --sandbox notebook.py

1. Reactivity that finally fixes the hidden state issues

Traditional notebooks will not be reactive. Because of this if I modify something in a single cell, nothing else updates by itself. I often find yourself re-running them just to maintain the outputs consistent. For example, consider the Jupyter Notebook below where on the left I define two variables, a and b, add them together to get a 3rd variable c, after which display the worth of c, which is 30.

In a standard notebook, changing the worth of a doesn’t update c robotically. The output stays stale until you rerun the cells yourself, which is the hidden state problem in motion | Image by Creator

Now, if I were to vary a to twenty as shown on the precise , c would still show 30 unless I re-ran the cell. That mismatch between code and output is the classic hidden state problem.

Marimo fixes this with reactive execution, where every cell is an element of a . Changes in a single cell robotically trigger updates in dependent cells. So, when a changes, marimo re-evaluates any dependent cells. See how c updates robotically when the worth of a is modified.

In marimo , changing a updates c immediately since the notebook is reactive and keeps all cells in sync | Image by Creator

This keeps my code and outputs perfectly in sync and it means I can share my notebooks with others without worrying in regards to the order through which they execute.

But Not at all times. Some cells are expensive to run, like those involving ML training or heavy data processing. The excellent news is that marimo supports lazy execution, which helps you to turn off auto-updates and trigger such cells only when needed.

2. Cell order now not breaks my workflow

Since marimo notebooks execute cells based on variable relationships and never their order on the page, this offers me the liberty to arrange my code in a way that is sensible to me. For example, I can place all my imports and helper functions at the underside to maintain the workspace clean.

This also opens up some fun use cases. I actually have used this to create small auto-graded quizzes where the reply key sits at the underside of the notebook. The quiz still works superb since the cell order doesn’t matter, and the answers will not be immediately visible to the person taking the quiz. (And yes, marimo comes with a dark mode too 😃.)

A fast demo of an auto-graded quiz made possible because cell order doesn’t matter. | Image by Creator

3. It’s principally a Python File under the hood

Since every marimo notebook is stored as a pure Python file, it solves my long-standing issue with versioning in Git. I can finally track changes cleanly without coping with messy JSON diffs. The notebook also becomes way more flexible. I can reuse it as a script, run it from the command line, and even turn it right into a small interactive app without changing anything.

Below, the precise side shows the marimo notebook view, while the left side shows the identical notebook opened as a traditional Python file in an editor.

Same notebook, two views : the Python source on the left and its interactive marimo notebook on the precise | Image by Creator

4. I can easily turn my Notebooks into apps

Turning a marimo notebook into an interactive app can also be easy. I can switch between Edit Mode and App View with a single click, and I never need to rewrite my code or add anything extra.

Here is an example notebook which converts temperatures from Celsius to Fahrenheit. The identical notebook may be viewed in App Mode using the default vertical layout.

Toggling between Edit Mode and App View with a single click | Image by Creator

This feature is particularly useful for creating interactive blogs, tutorials, and academic walkthroughs for libraries. When you’ve ever read , you already know the sensation of engaging with content fairly than simply reading it. Marimo gives an analogous feel and the Grid Layout makes it even higher since I can drag and drop outputs to rearrange the app the best way I need.

Using the Grid Layout to customize the app display in marimo | Image by Creator

5. Efficient Package Manager, so no more dependency headaches

Marimo comes with a built-in package manager that lets me install missing libraries right from the notebook. If a module is unavailable, marimo shows a small prompt, and I can install it with a click. This removes the same old back-and-forth with terminals.

built-in package manager in marimo | Image by Creator

Marimo also handles reproducibility for me. Once I run a notebook with the --sandbox flag, it tracks all packages and their exact versions and saves them contained in the notebook file as a top-level comment. There isn’t a need for a separate requirements.txt file since the notebook already carries all the pieces it needs.

Dependency metadata lives contained in the notebook itself, and shows up clearly if you open the marimo file as a traditional Python script. | Image by Creator

6. Built-in utilities for working with DataFrames.

When you spend a number of time exploring data, that is one among those features that immediately looks like a godsend. If you display a dataFrame in marimo, the default view is fully interactive and comes with several helpful tools right out of the box, like scrolling, pagination, automatic histograms for numeric columns, and straightforward sorting and filtering from the column headers. This hastens the EDA process for me, as visual exploration often gives higher insights.

Interactive dataframe view in marimo with built-in sorting, filtering, and histograms | Image by Auhtor

Marimo also lets me turn a DataFrame into an interactive input element. Using mo.ui.table,I can select rows and use those selections in downstream computations. The selections update reactively, which implies the remaining of my notebook updates robotically too.

Interactive row selection with mo.ui.table, feeding straight into downstream cells | Image by Creator

If I need to share a notebook with a business stakeholder, marimo features a UI dataframe editor that lets them drag and drop aggregations and transformations without writing any code. It even generates the equivalent Python code for each step.

Marimo’s UI dataframe editor lets business users explore data without writing code | Image by AUthor

And wait, that’s not all. There’s also a Data Explorer utility that lets me construct quick visualizations directly from the DataFrame.

Using the Data Explorer to select columns and generate fast visuals | Image by Creator

All of this makes early-stage data exploration much faster. As a substitute of juggling libraries or writing boilerplate code just to grasp a dataset, I can start analyzing and visualizing straight away contained in the notebook.

7. See the documentation as you type

Probably the most underrated features of marimo notebooks for me has been the Live Docs panel. I can see function docstrings, parameters, and examples without calling help utilities.

The panel can also be interactive, so I can scroll through long docstrings, check examples, and replica snippets into my notebook. If the docstring has formatted examples, marimo detects them and lets me copy them straight right into a recent cell, which has been very handy while learning recent libraries.

Live Docs in motion, showing documentation in real time as I type | Image by Creator

8. SQL Contained in the Notebook

Marimo has great support for SQL. I can stay in a single notebook and blend SQL and Python in a really natural way. I can write a SQL query inside a SQL cell, run it, and get the identical clean table view that marimo gives for DataFrames.

I may also run SQL on local files through DuckDB. An easy select * from "file.csv" just works. If I need to hook up with an actual database, I can do this from the side panel. Marimo lets me add different data sources, and once added, the tables show up directly within the notebook.

Running SQL on DataFrames and native files right inside Marimo without leaving the notebook | Image by Creator

9. Molab: marimo notebooks within the cloud

Molab is for marimo notebooks, what Google Colab is for Jupyter notebooks. You get all of the goodness of marimo notebooks within the cloud. You’ll be able to open Molab at molab.marimo.io, create recent notebooks, or open those you made earlier. It’s a terrific option when I need to spin up a notebook fast or avoid running things on my machine. Many popular Python packages are pre-installed, notebooks have persistent storage, and I can share, download, or upload them easily.

molab: marimo notebooks within the cloud | Image by Creator

One other neat feature is the GitHub integration. You’ll be able to go to the Molab URL and replace molab.marimo.io/notebooks with molab.marimo.io/github and it’ll allow you to open any notebook, Jupyter or marimo, that’s hosted on GitHub in Molab. Nevertheless, there is no such thing as a GPU support for now, like in Colab, but I’m sure that’s something that the team shall be working on.

10. Customizable LLMs integration

Marimo also has some really useful AI-assisted coding features in-built, which have been very helpful for me. To be honest, Jupyter also has a JupyterLab extension for AI features called JupyterAI (and yes, I actually have written about that too), but having AI support built into marimo removes a number of the friction for me.

I take advantage of AI in marimo mainly for 2 things. The primary is generating recent notebooks when I need to try a brand new library or make a fast demo. It saves me time since I would not have to hunt for toy datasets or arrange all the pieces from scratch.

Generating entire notebooks via AI in marimo | Image by Creator

The second is refactoring and debugging. Marimo’s AI assistant has the complete context of my notebook, so it will probably read my code and help me fix or clean it up right contained in the notebook.

AI assistant in marimo | Image by Creator

I also like that I can select different models for chat and for editing, and set my very own rules for a way I need code to be written. And if I need to avoid proprietary models, Ollama works superb as a provider too.

Conclusion

I’m not connected to the marimo team and this shouldn’t be a paid post, but my experience from using it in real projects. It is a long read because I desired to share how marimo has made my notebook work smoother in practice. I’m only calling out the parts that helped me essentially the most. The docs go much deeper and are one of the best place to explore all the pieces marimo has to supply.

ASK ANA

What are your thoughts on this topic?
Let us know in the comments below.

0 0 votes
Article Rating
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments

Share this article

Recent posts

0
Would love your thoughts, please comment.x
()
x