fix(table): allow freezing pandas index columns#9631
Conversation
`mo.ui.table(df, freeze_columns_left=[...])` rejected pandas index names even though the frontend already renders row headers as the leftmost columns and pins anything in the `left` array. Users who tried to freeze a named index, a MultiIndex level, or the default unnamed index hit `ValueError: Column '<name>' not found in table.` Validation now widens the left-side allowed set to include row-header names from `TableManager.get_row_headers()`. The right side keeps only table columns; passing a row-header name there raises a friendly error pointing the user to `freeze_columns_left`, since row headers can never render on the right. Non-pandas backends return no row headers, so their behavior is unchanged. Closes #9418
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
@kirangadhave I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
Pull request overview
Extends mo.ui.table(..., freeze_columns_left=...) validation to allow freezing pandas index-derived “row header” columns (including named indexes and MultiIndex levels), aligning backend validation with the frontend’s existing ability to pin row headers on the left.
Changes:
- Include row-header names (from
TableManager.get_row_headers()) as valid targets forfreeze_columns_left. - Reject row-header names in
freeze_columns_rightwith a clearer error directing users tofreeze_columns_left. - Add pandas-focused tests covering unnamed indexes, named indexes, MultiIndex levels, name-collision suffixing, and right-side rejection.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
marimo/_plugins/ui/_impl/table.py |
Expands frozen-column validation to include row headers on the left and adds a friendly error for row headers on the right. |
tests/_plugins/ui/_impl/test_table.py |
Adds regression tests ensuring pandas index row headers can be frozen on the left and are rejected on the right. |
There was a problem hiding this comment.
1 issue found across 2 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
The frontend generates a synthetic id like `__m_column__0` for unnamed row-header columns, so accepting `freeze_columns_left=[""]` on the backend passed validation but pinned nothing client-side. Reject the empty-string case up front and tell the user to name their index.
Reuse a single row_headers binding for the validation set and the component args instead of calling the manager twice.
|
🚀 Development release published. You may be able to view the changes at https://marimo.app?v=0.23.7-dev68 |
Summary
mo.ui.table(df, freeze_columns_left=[...])rejected pandas index names even though the frontend already renders row headers as the leftmost columns and pins anything in theleftarray. Users who tried to freeze a named index, a MultiIndex level, or the default unnamed index hitValueError: Column '<name>' not found in table.Validation now widens the left-side allowed set to include row-header names from
TableManager.get_row_headers(). The right side keeps only table columns; passing a row-header name there raises a friendly error pointing the user tofreeze_columns_left, since row headers can never render on the right. Non-pandas backends return no row headers, so their behavior is unchanged.Closes #9418