Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions marimo/_plugins/ui/_impl/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -980,14 +980,10 @@ def _get_column_summaries(

# For now, we only compute value counts for categorical columns and small tables
external_type = external_type.lower()
if (
column_type == "string"
and ("cat" in external_type or "enum" in external_type)
or (
column_type == "string"
and total_rows <= CHART_MAX_ROWS_STRING_VALUE_COUNTS
)
):
categorical_type = (
"cat" in external_type or "enum" in external_type
)
if column_type == "string" and categorical_type:
try:
val_counts = self._get_value_counts(
column, DEFAULT_VALUE_COUNTS_SIZE, total_rows
Expand Down
23 changes: 1 addition & 22 deletions tests/_plugins/ui/_impl/test_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -1055,29 +1055,8 @@ def test_rows_string_value_counts_limit(self) -> None:
)
table = ui.table(data)
summaries = table._get_column_summaries(ColumnSummariesArgs())
assert summaries.value_counts == {
"a": [
ValueCount(
value="unique values",
count=CHART_MAX_ROWS_STRING_VALUE_COUNTS,
)
]
}
assert summaries.data is None

# If >20k rows, we should not get value_counts
data = pd.DataFrame(
{
"a": [
str(i)
for i in range(CHART_MAX_ROWS_STRING_VALUE_COUNTS + 1)
]
}
)
table = ui.table(data)
summaries = table._get_column_summaries(ColumnSummariesArgs())
assert summaries.value_counts == {} # too many unique values
assert summaries.data is None
assert summaries.value_counts == {}

def test_with_smaller_limit(self, table: ui.table) -> None:
value_counts = table._get_value_counts(
Expand Down
Loading