Consider the following cells as well as the order of them.
out = df
if category.value:
out = df.filter(pl.col("survived") == int(category.value))
out
import polars as pl
df = pl.read_csv("https://calmcode.io/static/data/titanic.csv")
category = mo.ui.dropdown([str(e) for e in df["survived"].unique().to_list()])
category
If this were a Jupyter notebook, this would fail. You can't reference a dataframe before its loaded! However, in Marimo, this works just fine. The reason is that Marimo is reactive and that it will also try and figure out in what order the cells need to run. This means that the cells are not executed in order but rather in a way that makes sense depending on the code that is written in each cell. This is a different way of thinking about notebooks but it can be quite powerful.
This also helps motivate why the cell output is typically rendered on top of the cell as opposed to below in Marimo. You may also notice that some cells that contain boilerplate, like importing libraries/datasets, are moved down so that the focus may be on the more interesting visual bits.
In Jupyter this would not make sense, but in a reactive environment like Marimo, it does.