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
fix: use svg renderer and support enum charts (#5846)
Shahmir Varqha5c96ce49617e
diff --git a/frontend/src/components/data-table/column-summary/column-summary.tsx b/frontend/src/components/data-table/column-summary/column-summary.tsxindex 9fa4eb7ded..9c9e2c2c19 100644--- a/frontend/src/components/data-table/column-summary/column-summary.tsx+++ b/frontend/src/components/data-table/column-summary/column-summary.tsx@@ -47,6 +47,7 @@ export const TableColumnSummary = <TData, TValue>({spec={spec}width={70}height={30}+ renderer="svg"// @ts-expect-error - Our `loader.load` method is broader than VegaLite's typings but is functionally supported.loader={batchedLoader}style={{ minWidth: "unset", maxHeight: "40px" }}diff --git a/marimo/_data/preview_column.py b/marimo/_data/preview_column.pyindex e9bff8f05f..6e1fb3a3e4 100644--- a/marimo/_data/preview_column.py+++ b/marimo/_data/preview_column.py@@ -336,7 +336,7 @@ def _sanitize_dtypes("""Sanitize dtypes for vegafusion"""try:dtype = column_data.schema[column_name]- if dtype == nw.Categorical:+ if dtype == nw.Categorical or dtype == nw.Enum:column_data = column_data.with_columns(nw.col(column_name).cast(nw.String))diff --git a/tests/_data/test_preview_column.py b/tests/_data/test_preview_column.pyindex e86f1e596e..ad386cb3ee 100644--- a/tests/_data/test_preview_column.py+++ b/tests/_data/test_preview_column.py@@ -493,3 +493,23 @@ def test_sanitize_dtypes() -> None:result = _sanitize_dtypes(nw_df, "int128_col")assert result.schema["int128_col"] == nw.Int64+++ not DependencyManager.narwhals.has(), reason="narwhals not installed"+)[email protected](reason="Sanitizing is failing") # TODO: Fix this+def test_sanitize_dtypes_enum() -> None:+ import narwhals as nw+ import polars as pl++ df = pl.DataFrame(+ {+ "enum_col": ["A", "B", "A"],+ },+ schema={"enum_col": pl.Enum(["A", "B"])},+ )+ nw_df = nw.from_native(df)++ result = _sanitize_dtypes(nw_df, "enum_col")+ assert result.schema["enum_col"] == nw.String