SyncAI.news, a Varaisys broadcasting
How to Use Marimo for Interactive Data Analysis
AA

Abid Ali Awan

· 1 min read

EngineeringKDnuggets

How to Use Marimo for Interactive Data Analysis

Traditional Python notebooks are great for exploring data, but they can quickly become difficult to manage. Cells may be executed in the wrong order, results can become out of sync, and turning a notebook into something interactive usually means adding more tools or rebuilding the analysis somewhere else.

Marimo takes a much cleaner approach. It is an open-source reactive Python notebook where cells automatically update when their dependencies change. The notebook is also stored as a normal Python file, which makes it easier to reproduce, version with Git, and share.

In this guide, we will build a simple interactive data analysis dashboard using Marimo, Pandas, and Altair. We will create a dataset, add interactive filters, connect them to our analysis, build a visualization, and finally run the same notebook as an interactive application.

1. Installing Marimo

Start by installing Marimo along with the libraries we will use for the analysis:

pip install marimo pandas altair

You can also install Marimo using uv or Conda. There is also a marimo[recommended] installation that includes useful data tools such as DuckDB, Polars, and Altair.

Create your first notebook with:

python -m marimo edit analysis.py

This opens the Marimo editor in your browser. One thing I really like here is that, unlike Jupyter's .ipynb format, Marimo saves the notebook as a normal .py file.

2. Creating a Dataset

Now, let's create a slightly more realistic sales dataset that we can use throughout the rest of the tutorial. We will generate data for different products, regions, and quarters, along with units sold, pricing, and revenue.

One nice thing about Marimo is that you do not need any extra code just to inspect the DataFrame. By placing df at the end of the cell, Marimo automatically displays it as an interactive table where you can search, sort, and filter the data.

It works with both Pandas and Polars, so you can use whichever DataFrame library you already prefer.

Original source

This story was published by KDnuggets and written by Abid Ali Awan. SyncAI.news shows a preview; the complete article is on the publisher's site.

Read the full story on kdnuggets.com

Similar News