A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
docs: various improvements (#2984)
Akshay Agrawal8177cad44612
diff --git a/docs/_static/docs-df.mp4 b/docs/_static/docs-df.mp4new file mode 100644index 0000000000..4fc86d1658Binary files /dev/null and b/docs/_static/docs-df.mp4 differdiff --git a/docs/api/inputs/anywidget.md b/docs/api/inputs/anywidget.mdindex 922ebfa40a..ea4c63efbe 100644--- a/docs/api/inputs/anywidget.md+++ b/docs/api/inputs/anywidget.md@@ -1,4 +1,4 @@-# Custom UI elements+# Building custom UI elementsBuild custom UI plugins that hook into marimo's reactiveexecution engine by using [anywidget](https://anywidget.dev/).diff --git a/docs/getting_started/index.md b/docs/getting_started/index.mdindex 1f7614e6a6..991aa0e19b 100644--- a/docs/getting_started/index.md+++ b/docs/getting_started/index.md@@ -2,7 +2,7 @@Installing marimo gets you the `marimo` command-line interface (CLI), the entry point to all things marimo.-## Installation+## Install marimoBefore installing marimo, we recommend creating and activating a Python[virtual environment](https://docs.python.org/3/tutorial/venv.html#creating-virtual-environments).@@ -78,7 +78,7 @@ A tutorial notebook should open in your browser.Having installation issues? Reach out to us [at GitHub](https://github.com/marimo-team/marimo/issues) or [on Discord](https://marimo.io/discord?ref=docs).```-## Tutorials+## Run tutorials`marimo tutorial intro` opens the intro tutorial. List all tutorials with@@ -143,7 +143,7 @@ auto_instantiate = false:::-## Enable more features with optional dependencies+## Install optional dependencies for more featuresSome features require additional dependencies, which are not installed by default. This includes:@@ -180,7 +180,7 @@ conda install -c conda-forge marimo duckdb altair polars openai ruffThis will install: `duckdb`, `altair`, `polars`, `openai`, and `ruff`.-## GitHub Copilot and AI Assistant+## Enable GitHub Copilot and AI AssistantThe marimo editor natively supports [GitHub Copilot](https://copilot.github.com/),an AI pair programmer, similar to VS Code.@@ -196,10 +196,11 @@ marimo from `PyPI` if you need Copilot.marimo also comes with support for [other copilots](/guides/editor_features/ai_completion.md#codeium-copilot),and a built-in [AI assistant](/guides/editor_features/ai_completion.md#generate-code-with-our-ai-assistant) that helps you write code.-## VS Code extension+## Try our VS Code extension-If you prefer VS Code over terminal, try our-[VS Code extension](https://marketplace.visualstudio.com/items?itemName=marimo-team.vscode-marimo).+The best way to use marimo is through the CLI. However, if you prefer VS Code+over terminal, try our [VS Code+extension](https://marketplace.visualstudio.com/items?itemName=marimo-team.vscode-marimo).Use this extension to edit and run notebooks directly from VS Code, and to listall marimo notebooks in your current directory.diff --git a/docs/guides/coming_from/index.md b/docs/guides/coming_from/index.mdindex 87855e348e..11036f47af 100644--- a/docs/guides/coming_from/index.md+++ b/docs/guides/coming_from/index.md@@ -6,9 +6,9 @@:hidden:jupyter+ streamlitjupytextpapermill- streamlit```marimo is a **single tool** that replaces `jupyter`, `streamlit`, `jupytext`,@@ -17,6 +17,6 @@ marimo is a **single tool** that replaces `jupyter`, `streamlit`, `jupytext`,| Guide | Description || :--------------- | :----------------------------------- || {doc}`jupyter` | Transitioning from Jupyter notebooks |+| {doc}`streamlit` | Transitioning from Streamlit || {doc}`jupytext` | Transitioning from Jupytext || {doc}`papermill` | Transitioning from Papermill |-| {doc}`streamlit` | Transitioning from Streamlit |diff --git a/docs/guides/coming_from/jupyter.md b/docs/guides/coming_from/jupyter.mdindex 4060d8a852..1e0263ddb3 100644--- a/docs/guides/coming_from/jupyter.md+++ b/docs/guides/coming_from/jupyter.md@@ -3,15 +3,127 @@If you're coming from Jupyter, here are a few tips to help you adapt to marimonotebooks.-## Runtime configuration+## Adapting to marimo's execution model-You can [configure marimo's runtime](/guides/configuration/runtime_configuration.md) to not-autorun on startup or on cell execution.+The biggest difference between marimo and Jupyter is the execution model.-Even when autorun is disabled, your notebook remains a directed graph, with-marimo eliminating hidden state for you and marking cells as stale.+A **Jupyter** notebook is a **REPL**: you execute blocks of code one at a time,+and Jupyter has no understanding of how different blocks are related to each+other. As a result a Jupyter notebook can easily+accumulate "hidden state" (and hidden bugs) --- you might accidentally execute+cells out of order, or you might run (or delete) a cell but forget to re-run+cells that depended on its variables. Because of this, Jupyter notebooks+suffer from a [reproducibility crisis](/faq.md#faq-problems), with over+a third of Jupyter notebooks on GitHub failing to reproduce.-## HTML snapshots+Unlike Jupyter, **marimo** notebooks understand how different blocks of+code are related to each other, modeling your code as a graph on cells+based on variable declarations and references. This eliminates hidden+state, and it's also what enables marimo notebooks to be reused as+apps and scripts.++**By default, if you run a cell in marimo, all other cells that read its+variables run automatically.** While this ensures that your code and outputs are+in sync, it can take some time getting used to. **Here are some tips and tools to+help you adapt to marimo's execution model.**++### Configure marimo's runtime++[Configure marimo's runtime](/guides/configuration/runtime_configuration.md) to+not autorun on startup or on cell execution.++Even when autorun is disabled, marimo still tracks dependencies across cells,+marking dependents of a cell as stale when you run it. You can click a single+button to run all your stale cells and bring your notebook back up-to-date.++### Stop execution with `mo.stop`++Use [`mo.stop`](#marimo.stop) to stop a cell from executing if a condition+is met:++```+# if condition is True, the cell will stop executing after mo.stop() returns+mo.stop(condition)+# this won't be called if condition is True+expensive_function_call()+```++Use [`mo.stop()`](#marimo.stop) in conjunction with+[`mo.ui.run_button()`](#marimo.ui.run_button) to require a button press for+expensive cells:++```{eval-rst}+.. marimo-embed::+ :size: medium++ @app.cell+ def __():+ run_button = mo.ui.run_button()+ run_button+ return++ @app.cell+ def __():+ mo.stop(not run_button.value, mo.md("Click 👆 to run this cell"))+ mo.md("You clicked the button! 🎉")+ return+```++### Working with expensive notebooks++For more tips on adapting to marimo's execution model, see our guide+on [working with expensive notebooks](/guides/expensive_notebooks).+++## Adapting to marimo's restriction on redefining variables++marimo "compiles" your notebook cells into a directed graph on cells,+linked by variable declarations and references, reusing this graph to+run your notebook as a script or app. For marimo's compilation to work,+the same variable cannot be defined in multiple cells; otherwise, marimo+wouldn't know what order to run cells in.++To adapt to the restriction, we suggest:++1. Encapsulating code into functions when possible, to minimize the number+ of global variables.+2. Prefixing temporary variables with an underscore (`_my_temporary`), which+ makes the variable **local** to a cell.+3. Mutatinge variables in the cell that defines them.++When working with **dataframes**, you might be used to redefining the same `df`+variable in multiple cells. That won't work in marimo. Instead, either merge++_Don't_ do this:++```python+df = pd.DataFrame({"my_column": [1, 2]})+```++```python+df["another_column"] = [3, 4]+```++_Instead_, do this:++```python+df = pd.DataFrame({"my_column": [1, 2]})+df["another_column"] = [3, 4]+```++If you do need to transform a dataframe across multiple cells, you can+alias the dataframe:++```python+df = pd.DataFrame({"my_column": [1, 2]})+```++```python+augmented_df = df+augmented_df["another_column"] = [3, 4]+```++## Adapting to marimo's file formatmarimo stores notebooks as Python, not JSON. This lets you version notebookswith git, [execute them as scripts](/guides/scripts.md), and import named@@ -23,6 +135,13 @@ the "Auto-download as HTML" setting](/guides/configuration), which willperiodically snapshot your notebook as HTML to a `__marimo__` folder in thenotebook directory.+### Converting Jupyter notebooks to marimo notebooks++Convert Jupyter notebooks to marimo notebooks at the command-line:++```+marimo convert your_notebook.ipynb -o your_notebook.py+```## Interactive guidediff --git a/docs/guides/coming_from/streamlit.md b/docs/guides/coming_from/streamlit.mdindex 1d66e9250c..c02a82027d 100644--- a/docs/guides/coming_from/streamlit.md+++ b/docs/guides/coming_from/streamlit.md@@ -1,9 +1,11 @@# Coming from StreamlitIf you're familiar with Streamlit and looking to transition to marimo, read on.+The biggest difference between Streamlit and marimo is thatStreamlit can only be used for data apps, whereas marimo is a notebook-firstprogramming environment that makes it effortless to run notebooks as apps.+In addition, marimo is much more performant than streamlit.## Key Differences@@ -16,7 +18,7 @@ programming environment that makes it effortless to run notebooks as apps.notebooks, then migrate and refactor them into streamlit apps. With marimo,every notebook is automatically an app; there's no migration step needed.-2. **Execution Model**:+2. **Performance.**- marimo uses a reactive execution model that, on interaction or codechange, runs the minimal subset of notebook code needed to keep yournotebook up-to-date.diff --git a/docs/guides/exporting.md b/docs/guides/exporting.mdindex a9578c4429..c08b287f52 100644--- a/docs/guides/exporting.md+++ b/docs/guides/exporting.md@@ -1,4 +1,4 @@-# Exporting+# Exporting to HTML and other formatsExport marimo notebooks to other file formats at the command line usingdiff --git a/docs/guides/outputs.md b/docs/guides/outputs.mdindex 655b81de06..dc8a3581bd 100644--- a/docs/guides/outputs.md+++ b/docs/guides/outputs.md@@ -1,4 +1,4 @@-# Cell outputs+# Visualizing outputsThe last expression of a cell is its visual output, rendered above the cell.Outputs are included in the "app" or read-only view of the notebook. marimodiff --git a/docs/guides/overview.md b/docs/guides/overview.mdindex 1cc97667e9..1f1f6fb86c 100644--- a/docs/guides/overview.md+++ b/docs/guides/overview.md@@ -2,7 +2,9 @@marimo notebooks are **reactive**: they automatically react to your codechanges and UI interactions and keep your notebook up-to-date, not unlike a-spreadsheet.+spreadsheet. This makes your notebooks reproducibile, [eliminating hidden+state](/faq.md#faq-problems); it's also what enables marimo notebooks to double as+apps and Python scripts.```{admonition} Creating marimo notebooks:class: tip@@ -11,7 +13,17 @@ Make sure to first read the [getting started](/getting_started/index.md) page,which teaches you how to install marimo and create notebooks.```-## Cells+```{admonition} Working with expensive notebooks+:class: important++If you don't want cells to run automatically, the [runtime can be+configured](/guides/configuration/runtime_configuration.md) to be lazy, only+running cells when you ask for them to be run and marking affected cells as+stale. **See our guide on working with [expensive+notebooks](/guides/expensive_notebooks.md) for more tips.**+```++## How marimo executes cellsA marimo notebook is made of small blocks of Python code called **cells**._When you run a cell, marimo automatically runs all cells that read any global@@ -27,17 +39,6 @@ variables defined by that cell._ This is reactive execution.</figure></div>-```{admonition} Working with expensive notebooks-:class: important--If you don't want cells to run automatically, the [runtime can be-configured](/guides/configuration/runtime_configuration.md) to be lazy, only-running cells when you ask for them to be run and marking affected cells as-stale. **See our guide on working with [expensive-notebooks](/guides/expensive_notebooks.md) for more tips.**--```-**Execution order.**The order of cells on the page has no bearing on the order cells areexecuted in: execution order is determined by the variables@@ -60,6 +61,18 @@ cell's code just once, creating a directed acyclic graph based on theglobal names each cell defines and reads. This is how data flowsin a marimo notebook.+**The marimo library.**+We recommend starting each marimo notebook with a cell containing a single+line of code,++```python3+import marimo as mo+```+The marimo library lets you use+interactive UI elements, layout elements, dynamic markdown, and more in your+marimo notebooks.++```{admonition} Minimize variable mutation.:class: warning@@ -80,24 +93,11 @@ marimo tutorial dataflowor read the [reactivity guide](/guides/reactivity.md).-## The marimo library--marimo is both a notebook and a library. The marimo library lets you use-markdown, interactive UI elements, layout elements, and more in your marimo-notebooks.--We recommend starting each marimo notebook with a cell containing a single-line of code,--```python3-import marimo as mo-```--## Outputs+## Visualizing outputsmarimo visualizes the last expression of each cell as its **output**. Outputscan be any Python value, including markdown and interactive elements created-with the marimo library, _e.g._, `mo.md(...)`, `mo.ui.slider(...)`.+with the marimo library, (_e.g._, [`mo.md`](marimo.md), [`mo.ui.slider`](marimo.ui.slider)).You can even interpolate Python values into markdown (using `mo.md(f"...")`) andother marimo elements to build rich composite outputs:@@ -109,6 +109,12 @@ other marimo elements to build rich composite outputs:> Thanks to reactive execution, running a cell refreshes all the relevant outputs in your notebook.+The marimo library also comes with elements for laying out outputs, including+[`mo.hstack`](#marimo.hstack), [`mo.vstack`](#marimo.vstack),+[`mo.accordion`](#marimo.accordion), [`mo.ui.tabs`](#marimo.ui.tabs), [`mo.sidebar`](#marimo.sidebar),+[`mo.nav_menu`](#marimo.nav_menu), [`mo.ui.table`](#marimo.ui.table),+and [many more](https://docs.marimo.io/api/layouts/index.html).+For more on outputs, try these tutorials:```bash@@ -117,10 +123,10 @@ marimo tutorial plotsmarimo tutorial layout```-## Interactive elements+## Creating interactive elementsThe marimo library comes with many interactive stateful elements in-`marimo.ui`, including simple ones like sliders, dropdowns, text fields, and file+[`marimo.ui`](/api/inputs/index), including simple ones like sliders, dropdowns, text fields, and fileupload areas, as well as composite ones like forms, arrays, and dictionariesthat can wrap other UI elements.@@ -131,7 +137,7 @@ that can wrap other UI elements.</div>**Using UI elements.**-To use a UI element, create it with `marimo.ui` and **assign it to a global+To use a UI element, create it with `mo.ui` and **assign it to a globalvariable.** When you interact with a UI element in your browser (_e.g._,sliding a slider), _marimo sends the new value back to Python and reactivelyruns all cells that use the element_, which you can access via its `value`@@ -142,8 +148,16 @@ attribute.> and apps._marimo can only synchronize UI elements that are assigned to-global variables._ You can use composite elements like `mo.ui.array` and-`mo.ui.dictionary` if the set of UI elements is not known until runtime.+global variables._ Use composite elements like [`mo.ui.array`](marimo.ui.array) and+[`mo.ui.dictionary`](marimo.ui.dictionary) if the set of UI elements is not+known until runtime.++```{admonition} Using buttons to execute cells+:class: tip++Use [`mo.ui.run_button`](marimo.ui.run_button) to create a button that+triggers computation when clicked; see our recipes for [an example](/recipes#create-a-button-that-triggers-computation-when-clicked).+```For more on interactive elements, run the UI tutorial:@@ -151,29 +165,7 @@ For more on interactive elements, run the UI tutorial:marimo tutorial ui```-### Composite elements--marimo's composite UI elements let you wrap other UI-elements to create powerful UIs. For example,-`marimo.ui.form` lets you gate elements on submission, while-`marimo.ui.dictionary` and `marimo.ui.array` let you batch arbitrary-collections of elements.--<div align="center">-<figure>-<img src="/_static/readme-ui-form.gif" width="600px"/>-</figure>-</div>--## Layout--The marimo library also comes with elements for laying out outputs, including-[`mo.hstack`](#marimo.hstack), [`mo.vstack`](#marimo.vstack),-[`mo.accordion`](#marimo.accordion), [`mo.ui.tabs`](#marimo.ui.tabs), [`mo.sidebar`](#marimo.sidebar),-[`mo.nav_menu`](#marimo.nav_menu), [`mo.ui.table`](#marimo.ui.table),-and [many more](https://docs.marimo.io/api/layouts/index.html).--## SQL+## Query dataframes and databases with SQLmarimo has built-in support for SQL: you can query Python dataframes,databases, CSVs, Google Sheets, or anything else. After executing your query,@@ -188,7 +180,8 @@ to go back and forth between SQL and Python.</div>To create a SQL cell, click on the SQL button that appears at the bottom of the-cell array, or right click the create cell button next to a cell.+cell array, or right click the create cell button next to a cell. Today,+SQL in marimo is executed using [duckdb](https://duckdb.org/docs/).To learn more, run the SQL tutorial:diff --git a/docs/guides/working_with_data/dataframes.md b/docs/guides/working_with_data/dataframes.mdindex 9b06178142..a852c2fbba 100644--- a/docs/guides/working_with_data/dataframes.md+++ b/docs/guides/working_with_data/dataframes.md@@ -1,28 +1,32 @@-# Dataframes+# Interactive dataframes-**marimo makes you more productive when working with dataframes**, the most-common Python tool for interacting with data.+**marimo makes you more productive when working with dataframes**.- [Display dataframes](#displaying-dataframes) in a rich, interactive table and chart views-- [Select data](#selecting-dataframes) from tables or charts and get selections back as dataframes- [Transform dataframes](#transforming-dataframes) with filters, groupbys,aggregations, and more, **no code required**+- [Select data](#selecting-dataframes) from tables or charts and get selections+ back in Python as dataframes_marimo integrates with [Pandas](https://pandas.pydata.org/) and-[Polars](https://pola.rs) dataframes natively. The examples on this page-use Pandas, but Polars works too._+[Polars](https://pola.rs) dataframes natively_.## Displaying dataframes-You can display dataframes directly in the output area of a cell, by including-them in the last expression of the cell:+marimo lets you page through, search, sort, and filter dataframes, making it+extremely easy to get a feel for your data.-<div align="center"><figure>-<img src="/_static/docs-dataframe-output.png"/>-<figcaption>A raw dataframe output</figcaption>+<video autoplay controls loop width="100%" height="100%" align="center" src="/_static/docs-df.mp4">+</video>+<figcaption>marimo brings dataframes to life.</figcaption></figure>-</div>++Display dataframes by including them in the last expression of the+cell, just like any other object.++::::{tab-set}+:::{tab-item} pandas```pythonimport pandas as pd@@ -32,85 +36,46 @@ df = pd.read_json()df```--By default the dataframe is displayed using `mo.ui.table`, which provides a-a rich, interactive table view. You can also use `mo.plain` to revert to the-to the default HTML representation.-+:::+:::{tab-item} polars```python-df = pd.read_json(+import polars as pl++df = pl.read_json("https://raw.githubusercontent.com/vega/vega-datasets/master/data/cars.json")-mo.plain(df)+df```+:::+::::-**Rich displays.**-You can display dataframes in rich tables or charts using the-[`mo.ui.table`](/api/inputs/table/) or [`mo.ui.altair_chart`](/api/plotting/)-elements.--<div align="center">-<figure>-<img src="/_static/docs-dataframe-visualizations.png"/>-<figcaption>Rich, interactive displays</figcaption>-</figure>-</div>+To opt out of the rich dataframe viewer, use [`mo.plain`](marimo.plain):+::::{tab-set}+:::{tab-item} pandas```python-import marimo as mo-import altair as alt-import pandas as pd-df = pd.read_json("https://raw.githubusercontent.com/vega/vega-datasets/master/data/cars.json"-)[["Horsepower", "Miles_per_Gallon", "Origin"]]--mo.hstack(- [- mo.ui.table(df),- mo.ui.altair_chart(- alt.Chart(df)- .mark_point()- .encode(x="Horsepower", y="Miles_per_Gallon", color="Origin")- ),- ],- widths="equal",)+mo.plain(df)```--## Selecting dataframes--Select data in a [table](#marimo.ui.table) or [Plotly](#marimo.ui.plotly)/[Altair](#marimo.ui.altair_chart) plot,-and your selection is _automatically sent to Python as a Pandas dataframe_.--<div align="center">-<figure>-<img src="/_static/docs-dataframe-table.gif"/>-<figcaption>Select rows in a table, get them back as a dataframe</figcaption>-</figure>-</div>--```python-# Cell 1 - display a dataframe-import marimo as mo-import pandas as pd--df = pd.DataFrame({"a": [1, 2, 3], "b": [4, 5, 6]})-table = mo.ui.table(df, selection="multi")-table-```-+:::+:::{tab-item} polars```python-# Cell 2 - display the selection-table.value+df = pl.read_json(+ "https://raw.githubusercontent.com/vega/vega-datasets/master/data/cars.json"+)+mo.plain(df)```+:::+::::## Transforming dataframes### No-code transformationsUse [`mo.ui.dataframe`](/api/inputs/dataframe/) to interactively-transform a dataframe with a GUI, no coding required!. When you're done, you+transform a dataframe with a GUI, no coding required. When you're done, youcan copy the code that the GUI generated for you and paste it into yournotebook.@@ -121,6 +86,9 @@ notebook.</figure></div>++::::{tab-set}+:::{tab-item} pandas```python# Cell 1import marimo as mo@@ -136,6 +104,25 @@ transformed_df# transformed_df.value holds the transformed dataframetransformed_df.value```+:::+:::{tab-item} polars+```python+# Cell 1+import marimo as mo+import pandas as pl++df = pl.DataFrame({"person": ["Alice", "Bob", "Charlie"], "age": [20, 30, 40]})+transformed_df = mo.ui.dataframe(df)+transformed_df+```++```python+# Cell 2+# transformed_df.value holds the transformed dataframe+transformed_df.value+```+:::+::::<div align="center"><figure>@@ -148,6 +135,8 @@ transformed_df.valueCreate custom filters with marimo UI elements, like sliders and dropdowns.+::::{tab-set}+:::{tab-item} pandas```python# Cell 1 - create a dataframedf = pd.DataFrame({"person": ["Alice", "Bob", "Charlie"], "age": [20, 30, 40]})@@ -164,114 +153,91 @@ age_filterfiltered_df = df[df["age"] < age_filter.value]mo.ui.table(filtered_df)```--## Polars support--marimo provides first-class support for [Polars](https://pola.rs/), a modern, high-performance alternative to Pandas. You can use Polars dataframes seamlessly with marimo's interactive features, just like you would with Pandas.--### Displaying Polars dataframes--Polars dataframes can be displayed directly in marimo cells:--```python-import polars as pl--df = pl.DataFrame({- "A": [1, 2, 3, 4, 5],- "B": ["a", "b", "c", "d", "e"],- "C": [1.1, 2.2, 3.3, 4.4, 5.5]-})-df-```--This will render an interactive rich table view of the Polars dataframe.--### Rich visualizations--You can use `mo.ui.table` or `mo.ui.altair_chart` for displaying Polars dataframes getting-the row selections or points on a chart back as a Polars dataframe.-+:::+:::{tab-item} polars```pythonimport marimo as moimport polars as pl-import altair as altdf = pl.DataFrame({- "category": ["A", "B", "C", "D"],- "value": [10, 20, 15, 25]+ "name": ["Alice", "Bob", "Charlie", "David"],+ "age": [25, 30, 35, 40],+ "city": ["New York", "London", "Paris", "Tokyo"]})+age_filter = mo.ui.slider.from_series(df["age"], label="Max age")+city_filter = mo.ui.dropdown.from_series(df["city"], label="City")-chart = mo.ui.altair_chart(- alt.Chart(df).mark_bar().encode(- x="category",- y="value"- )-)-chart+mo.hstack([age_filter, city_filter])``````python# Cell 2-# chart.value holds the selected data as a Polars dataframe-chart.value+filtered_df = df.filter((pl.col("age") <= age_filter.value) & (pl.col("city") == city_filter.value))+mo.ui.table(filtered_df)```+:::+::::-### Interactive transformations-Use `mo.ui.dataframe` to interactively transform Polars dataframes:+## Select dataframe rows+Display dataframes as interactive, [selectable+charts](/guides/working_with_data/plotting) using+[`mo.ui.altair_chart`](marimo.ui.altair_chart) or+[`mo.ui.plotly`](marimo.ui.plotly), or as a row-selectable table with+(`mo.ui.table`)(marimo.ui.table). Select points in the chart, or select a table+row, and your selection is _automatically sent to Python as a subset of the original+dataframe_.++<div align="center">+<figure>+<img src="/_static/docs-dataframe-table.gif"/>+<figcaption>Select rows in a table, get them back as a dataframe</figcaption>+</figure>+</div>+++::::{tab-set}+:::{tab-item} pandas```python+# Cell 1 - display a dataframeimport marimo as mo-import polars as pl--df = pl.DataFrame({- "name": ["Alice", "Bob", "Charlie", "David"],- "age": [25, 30, 35, 40],- "city": ["New York", "London", "Paris", "Tokyo"]-})+import pandas as pd-transformed_df = mo.ui.dataframe(df)-transformed_df+df = pd.DataFrame({"a": [1, 2, 3], "b": [4, 5, 6]})+table = mo.ui.table(df, selection="multi")+table``````python-# Cell 2-# transformed_df.value holds the transformed dataframe-transformed_df.value+# Cell 2 - display the selection+table.value```--### Filters for Polars dataframes--Create custom filters for Polars dataframes using marimo UI elements:-+:::+:::{tab-item} polars```python+# Cell 1 - display a dataframeimport marimo as mo-import polars as pl+import pandas as pl-df = pl.DataFrame({- "name": ["Alice", "Bob", "Charlie", "David"],- "age": [25, 30, 35, 40],- "city": ["New York", "London", "Paris", "Tokyo"]-})--age_filter = mo.ui.slider.from_series(df["age"], label="Max age")-city_filter = mo.ui.dropdown.from_series(df["city"], label="City")--mo.hstack([age_filter, city_filter])+df = pl.DataFrame({"a": [1, 2, 3], "b": [4, 5, 6]})+table = mo.ui.table(df, selection="multi")+table``````python-# Cell 2-filtered_df = df.filter((pl.col("age") <= age_filter.value) & (pl.col("city") == city_filter.value))-mo.ui.table(filtered_df)+# Cell 2 - display the selection+table.value```+:::+::::-### Example notebook+## Example notebookFor a comprehensive example of using Polars with marimo, check out our [Polars example notebook](https://github.com/marimo-team/marimo/blob/main/examples/third_party/polars/polars_example.py).-You can run it yourself with:+Run it with:```bashmarimo edit https://raw.githubusercontent.com/marimo-team/marimo/main/examples/third_party/polars/polars_example.pydiff --git a/docs/guides/working_with_data/sql.md b/docs/guides/working_with_data/sql.mdindex c57f1725c8..95d41bc79c 100644--- a/docs/guides/working_with_data/sql.md+++ b/docs/guides/working_with_data/sql.md@@ -1,4 +1,4 @@-# SQL+# Using SQLmarimo lets you can mix and match **Python and SQL**: Use SQL to queryPython dataframes (or databases like SQLite and Postgres), and get