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
improvement: add param to show dtypes in table header (#5693)
Shahmir Varqha62f4e78c621c
diff --git a/frontend/src/plugins/impl/DataTablePlugin.tsx b/frontend/src/plugins/impl/DataTablePlugin.tsxindex 8d5ef8e1df..2ef09f4c9e 100644--- a/frontend/src/plugins/impl/DataTablePlugin.tsx+++ b/frontend/src/plugins/impl/DataTablePlugin.tsx@@ -163,6 +163,7 @@ interface Data<T> {showDownload: boolean;showFilters: boolean;showColumnSummaries: boolean | "stats" | "chart";+ showDataTypes: boolean;showPageSizeSelector: boolean;showColumnExplorer: boolean;showChartBuilder: boolean;@@ -228,6 +229,7 @@ export const DataTablePlugin = createPlugin<S>("marimo-table")showColumnSummaries: z.union([z.boolean(), z.enum(["stats", "chart"])]).default(true),+ showDataTypes: z.boolean().default(true),showPageSizeSelector: z.boolean().default(true),showColumnExplorer: z.boolean().default(true),showChartBuilder: z.boolean().default(true),@@ -669,6 +671,7 @@ const DataTableComponent = ({showPageSizeSelector,showColumnExplorer,showChartBuilder,+ showDataTypes,rowHeaders,fieldTypes,paginationState,@@ -743,9 +746,13 @@ const DataTableComponent = ({const memoizedTextJustifyColumns = useDeepCompareMemoize(textJustifyColumns);const memoizedWrappedColumns = useDeepCompareMemoize(wrappedColumns);const memoizedChartSpecModel = useDeepCompareMemoize(chartSpecModel);- const showDataTypes = Boolean(fieldTypes);const shownColumns = memoizedClampedFieldTypes.length;+ // If the field types are not set, we don't show them+ if (!fieldTypes) {+ showDataTypes = false;+ }+const columns = useMemo(() =>generateColumns({diff --git a/frontend/src/plugins/impl/data-frames/DataFramePlugin.tsx b/frontend/src/plugins/impl/data-frames/DataFramePlugin.tsxindex cef25c5d5a..024fdc937f 100644--- a/frontend/src/plugins/impl/data-frames/DataFramePlugin.tsx+++ b/frontend/src/plugins/impl/data-frames/DataFramePlugin.tsx@@ -276,6 +276,7 @@ export const DataFrameComponent = memo(showFilters={false}search={search}showColumnSummaries={false}+ showDataTypes={true}get_column_summaries={getColumnSummaries}showPageSizeSelector={(total_rows && total_rows > 5) || false}showColumnExplorer={false}diff --git a/marimo/_plugins/ui/_impl/table.py b/marimo/_plugins/ui/_impl/table.pyindex d05d5a6061..3e4d8b3704 100644--- a/marimo/_plugins/ui/_impl/table.py+++ b/marimo/_plugins/ui/_impl/table.py@@ -315,6 +315,8 @@ class table(show_column_summaries (Union[bool, Literal["stats", "chart"]], optional): Whether to show column summaries.Defaults to True when the table has less than 40 columns and at least 10 rows, False otherwise.If "stats", only show stats. If "chart", only show charts.+ show_data_types (bool, optional): Whether to show data types of columns in the table header.+ Defaults to True.show_download (bool, optional): Whether to show the download button.Defaults to True for dataframes, False otherwise.format_mapping (Dict[str, Union[str, Callable[..., Any]]], optional): A mapping from@@ -409,6 +411,7 @@ class table(show_column_summaries: Optional[Union[bool, Literal["stats", "chart"]]] = None,+ show_data_types: bool = True,format_mapping: Optional[dict[str, Union[str, Callable[..., Any]]]] = None,@@ -650,6 +653,7 @@ class table("show-download": show_downloadand self._manager.supports_download(),"show-column-summaries": show_column_summaries,+ "show-data-types": show_data_types,"show-page-size-selector": show_page_size_selector,"show-column-explorer": show_column_explorer,"show-chart-builder": show_chart_builder,