Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors
Filter by Categories
About Article
Analyze Data
Archive
Best Practices
Better Outputs
Blog
Code Optimization
Code Quality
Command Line
Daily tips
Dashboard
Data Analysis & Manipulation
Data Engineer
Data Visualization
DataFrame
Delta Lake
DevOps
DuckDB
Environment Management
Feature Engineer
Git
Jupyter Notebook
LLM
LLM
Machine Learning
Machine Learning
Machine Learning & AI
Manage Data
MLOps
Natural Language Processing
NumPy
Pandas
Polars
PySpark
Python Tips
Python Utilities
Python Utilities
Scrape Data
SQL
Testing
Time Series
Tools
Visualization
Visualization & Reporting
Workflow & Automation
Workflow Automation

marimo: Reactive Notebooks for Effortless Visualizations

Table of Contents

marimo: Reactive Notebooks for Effortless Visualizations

Motivation

Interactive data visualizations are essential in data science workflows, allowing analysts and scientists to dynamically explore data and communicate findings effectively.

Working with interactive widgets in traditional notebooks requires complex widget setup, output management, and explicit function definitions for even simple interactions. With Marimo’s reactive notebooks you can effortless create more visualizations helping streamline workflows significantly.

import ipywidgets as widgets

a = widgets.IntSlider(min=1, max=20)

def f(a):
    print(f'{"🍃" * a}')

out = widgets.interactive_output(f, {'a': a})

widgets.VBox([widgets.VBox([a]), out])

Introduction to marimo

marimo is a reactive notebook that automatically manages dependencies between cells and UI elements, ensuring consistency throughout the notebook.

Installation:

pip install marimo

As covered in the article about reproducible and consistent notebooks, marimo automatically re-runs dependent cells when changes occur. In this post, we will cover its interactive UI elements feature.

Interactive UI elements promote data visualization

marimo simplifies the same leaf visualization with a more intuitive approach:

import marimo as mo

# Simple slider creation
leaves = mo.slider(1, 20)

# Direct output without manual widget management
mo.md(f'{"🍃" * leaves.value}')

Conclusion

marimo’s interactive UI elements provide a more intuitive and maintainable way to create interactive data applications. By automatically handling state changes and dependencies, it eliminates common sources of errors and inconsistencies found in traditional notebook environments.

Reactive Notebooks and easy visualizations are just one way Marimo improves productivity. For a comprehensive breakdown of many of Marimo’s features, check out my main Marimo article here!

Link to marimo

Leave a Comment

Your email address will not be published. Required fields are marked *

0
    0
    Your Cart
    Your cart is empty
    Scroll to Top

    Work with Khuyen Tran

    Work with Khuyen Tran