[feature] Add hide_index and hide_header to st.table#14113
[feature] Add hide_index and hide_header to st.table#14113lukasmasuch merged 6 commits intodevelopfrom
hide_index and hide_header to st.table#14113Conversation
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
✅ PR preview is ready!
|
There was a problem hiding this comment.
Pull request overview
This PR adds hide_index and hide_header parameters to st.table() with intelligent auto-hide behavior. When set to None (default), hide_index auto-hides default RangeIndex (0, 1, 2...) while showing custom indices, and hide_header auto-hides headers for data formats without user-defined column names (dict, list, numpy arrays). Both parameters accept explicit True/False values to override the auto-hide behavior.
Changes:
- Added two boolean protobuf fields to the Table message for hide_index and hide_header
- Implemented backend logic for auto-detection of RangeIndex and simple data formats
- Updated frontend rendering to conditionally hide index columns and header rows
- Added comprehensive unit tests (Python and TypeScript) and E2E visual snapshot tests
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
proto/streamlit/proto/Table.proto |
Added hide_index and hide_header boolean fields (3 and 4) to Table message |
lib/streamlit/elements/table.py |
Added _compute_hide_index and _compute_hide_header helper functions, parameter handling, and auto-hide logic based on data format |
lib/tests/streamlit/elements/table_test.py |
Added comprehensive unit tests for auto-hide logic, explicit values, Styler support, and combined scenarios |
frontend/lib/src/components/elements/Table/Table.tsx |
Implemented conditional rendering of index columns and headers, updated sticky positioning logic |
frontend/lib/src/components/elements/Table/Table.test.tsx |
Added unit tests verifying hideIndex and hideHeader rendering with positive and negative assertions |
e2e_playwright/st_table.py |
Added test app with 10 new table examples covering all hide_index/hide_header scenarios |
e2e_playwright/st_table_test.py |
Added 10 E2E tests with visual snapshots and DOM assertions for the new parameters |
Use the more idiomatic assert_called_once() assertion method instead of manually checking call_count == 1, as suggested in code review.
## Describe your changes Automated snapshot updates for #14113 created via the snapshot autofix CI workflow. This workflow was triggered by adding the `update-snapshots` label to a PR after Playwright E2E tests failed with snapshot mismatches. **Updated snapshots:** 182 file(s)⚠️ **Please review the snapshot changes carefully** - they could mask visual bugs if accepted blindly. This PR targets a feature branch and can be merged without review approval. Co-authored-by: Streamlit Bot <[email protected]>
SummaryThis PR adds two new parameters —
Changes span the full stack: protobuf schema ( Code QualityThe implementation is clean and follows existing patterns well. Backend (
Frontend (
Protobuf (
Docstrings: The new parameter docstrings follow the NumPy style, use double backticks for inline code, and list options with bullet points — consistent with existing parameter documentation. The two new examples (4 and 5) are useful but lack Test CoverageTest coverage is thorough across all layers: Python unit tests (
Frontend unit tests (
E2E tests (
Minor observations on E2E tests:
Missing but optional test coverage:
Backwards CompatibilityThis is a behavioral breaking change for existing users. With the default
This is reflected in the updated E2E snapshots — many existing numbered snapshots (st_table-0 through st_table-13, st_table-27 through st_table-37) were updated because the visual appearance changed. Users can opt out with Wire protocol compatibility is preserved:
Security & RiskNo security concerns identified. The changes are purely display-related:
Regression risk is low-to-moderate:
Accessibility
Recommendations
VerdictAPPROVED: Well-implemented feature with clean code, thorough test coverage across all layers, and correct protobuf wire compatibility. The auto-hide behavioral change is intentional and users can opt out. Minor improvements (typing tests, E2E consolidation, release notes) are recommended but not blocking. This is an automated AI review by |
SummaryThis PR adds two new parameters —
Changes span the full stack: protobuf schema ( Both reviewers agreed this is a well-structured, cleanly implemented feature. One reviewer (gpt-5.3-codex-high) raised a critical concern about double-consumption of one-shot data sources that was verified to be incorrect upon code inspection (see Code Quality section below). Code QualityThe implementation is clean and follows existing patterns well across all layers. Backend (
Resolved disagreement — double-consumption claim: gpt-5.3-codex-high flagged a merge-blocking regression claiming one-shot data sources (generators, DB cursors) are consumed twice. After tracing the code, this is not a real issue. The flow for one-shot inputs is:
The fallback path at line 138 only executes for non-DataFrame, non-Styler, non-unevaluated data (plain lists, dicts, numpy arrays, etc.) — none of which are one-shot sources. The Frontend (
Protobuf (
Docstrings: The new parameter docstrings follow the NumPy style, use double backticks for inline code, and list options with bullet points — consistent with existing documentation. The two new examples (4 and 5) lack Test CoverageBoth reviewers agreed test coverage is thorough. Coverage spans all layers: Python unit tests (
Frontend unit tests (
E2E tests (
Minor gaps (non-blocking):
Backwards CompatibilityBoth reviewers agreed the wire protocol is compatible:
This is an intentional behavioral change for existing users. With the default
Users can opt out with Security & RiskBoth reviewers agreed: no security concerns. Changes are purely display-related with no new endpoints, authentication changes, or unsafe input handling. Regression risk is low. The auto-hide logic for edge-case data types (Polars, Modin, Snowpark) goes through the AccessibilityBoth reviewers agreed on the accessibility implications:
Recommendations
VerdictAPPROVED: Well-implemented feature with clean code, thorough test coverage across all layers, and correct protobuf wire compatibility. The critical concern raised by one reviewer about double-consumption of one-shot data sources was verified to be incorrect — the code specifically handles this via the Consolidated review by 📋 Review by `gpt-5.3-codex-high`SummaryThis PR adds I found one merge-blocking regression in the backend implementation for non-DataFrame inputs. Code Quality
Test CoverageCoverage is strong for the main happy paths:
Gap:
Backwards CompatibilityThe protobuf field additions are additive ( Behavioral default changes (auto-hiding some index/header cases) are intentional per PR scope. Security & RiskNo direct security issues identified. Primary risk is functional regression for data correctness on single-pass data sources (cursor/iterator-like inputs), which can silently drop displayed rows. AccessibilityFrontend changes keep semantic table markup and do not introduce new interactive controls.
Recommendations
VerdictCHANGES REQUESTED: The feature implementation is close, but the current backend logic can consume one-shot inputs before rendering and produce incorrect table output. This is an automated AI review by 📋 Review by `opus-4.6-thinking`SummaryThis PR adds two new parameters —
Changes span the full stack: protobuf schema ( Code QualityThe implementation is clean and follows existing patterns well. Backend (
Frontend (
Protobuf (
Docstrings: The new parameter docstrings follow the NumPy style, use double backticks for inline code, and list options with bullet points — consistent with existing parameter documentation. The two new examples (4 and 5) are useful but lack Test CoverageTest coverage is thorough across all layers: Python unit tests (
Frontend unit tests (
E2E tests (
Minor observations on E2E tests:
Missing but optional test coverage:
Backwards CompatibilityThis is a behavioral breaking change for existing users. With the default
This is reflected in the updated E2E snapshots — many existing numbered snapshots (st_table-0 through st_table-13, st_table-27 through st_table-37) were updated because the visual appearance changed. Users can opt out with Wire protocol compatibility is preserved:
Security & RiskNo security concerns identified. The changes are purely display-related:
Regression risk is low-to-moderate:
Accessibility
Recommendations
VerdictAPPROVED: Well-implemented feature with clean code, thorough test coverage across all layers, and correct protobuf wire compatibility. The auto-hide behavioral change is intentional and users can opt out. Minor improvements (typing tests, E2E consolidation, release notes) are recommended but not blocking. This is an automated AI review by |
hide_index and hide_header to st.table
- Add typing test for hide_index and hide_header parameter types - Consolidate 10 E2E tests into 2 aggregated scenario tests to reduce browser loads - Add .. output:: directives to docstring examples 4 and 5 for consistency
Unevaluated data objects (Snowpark, PySpark, generators, DB cursors, etc.) always produce a default RangeIndex when converted to pandas DataFrame. Instead of passing a pre-converted DataFrame to _compute_hide_index, we now directly assume hide_index=True for these data types. This removes the data_df parameter from _compute_hide_index and simplifies the control flow in st.table.
Co-authored-by: Laura Wilby <[email protected]>
Describe your changes
Adds
hide_indexandhide_headerparameters tost.table()with intelligent auto-hide behavior:hide_index: Auto-hides default RangeIndex (0, 1, 2...) while showing custom indiceshide_header: Auto-hides headers for data without user-defined column names (dict, list, numpy arrays)Both parameters accept
True/Falseto explicitly control visibility, orNone(default) for auto-hide behavior.Github Issues
hide_indextost.table#9251Testing Plan
lib/tests/streamlit/elements/table_test.py— Tests auto-hide logic, explicit values, Styler supportfrontend/lib/src/components/elements/Table/Table.test.tsx— Tests frontend rendering with hideIndex/hideHeadere2e_playwright/st_table_test.py— Visual snapshot tests for all hide_index/hide_header scenarios