Skip to content

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.

fix: don't render dataframes in mo.ui.table if they contain nested datastructures (#1708)

Myles Scolnick909125c9aced
diff --git a/marimo/_output/formatters/df_formatters.py b/marimo/_output/formatters/df_formatters.py
index cb109c27f6..a5f271c646 100644
--- a/marimo/_output/formatters/df_formatters.py
+++ b/marimo/_output/formatters/df_formatters.py
@@ -20,6 +20,15 @@ class PolarsFormatter(FormatterFactory):
def _show_marimo_dataframe(
df: pl.DataFrame,
) -> tuple[KnownMimeType, str]:
+ # If has structured don't display in the table
+ for col in df.get_columns():
+ if (
+ col.dtype == pl.Struct
+ or col.dtype == pl.List
+ or col.dtype == pl.Array
+ ):
+ return ("text/html", df._repr_html_())
+
return table(df, selection=None, pagination=True)._mime_()
diff --git a/marimo/_smoke_tests/bugs/1706.py b/marimo/_smoke_tests/bugs/1706.py
new file mode 100644
index 0000000000..2baf24ffc5
--- /dev/null
+++ b/marimo/_smoke_tests/bugs/1706.py
@@ -0,0 +1,33 @@
+import marimo
+
+__generated_with = "0.6.25"
+app = marimo.App(width="medium")
+
+
+def __():
+ import marimo as mo
+ import polars as pl
+ import numpy as np
+
+ df = pl.DataFrame(
+ {"a": [np.zeros(5) for i in range(5)]}, schema={"a": pl.Array(pl.Float64, 5)}
+ )
+ df
+ return df, mo, np, pl
+
+
+def __(df, mo):
+ mo.plain(df)
+ return
+
+
+def __(df):
+ df.get_columns()[0].dtype
+ return
+
+
+if __name__ == "__main__":
+ app.run()