Displaying a DataFrame in Streamlit
Streamlit provides built-in functions to display DataFrames, making it easy to visualize tabular data in an interactive way. The primary methods for displaying DataFrames are st.dataframe() and st.table().
Basic Example
import streamlit as st
import pandas as pd
# Sample DataFrame
data = pd.DataFrame({
'Name': ['Alice', 'Bob', 'Charlie'],
'Age': [25, 30, 35],
'Score': [85, 90, 78]
})
st.dataframe(data) Using st.table() for Static Data
If you need a non-scrollable static table, use st.table():
st.table(data) Interactive DataFrame with Filtering
Streamlit allows users to filter and edit data using interactive widgets:
import numpy as np
data['Score'] = np.random.randint(50, 100, size=len(data))
st.dataframe(data.style.highlight_max(axis=0)) Displaying Data in Evidence
For structured data visualization and reporting, Evidence provides a way to display tabular data using the <DataTable/> component. Unlike Streamlit, which requires Python scripting, Evidence enables query-driven, dynamic tables that update automatically based on the dataset.
Example: Data Table in Evidence
```sql my_query
SELECT name, age, score
FROM users
```
<DataTable data={my_query} /> This approach ensures that tables remain dynamic and query-driven, allowing users to explore live data without manual refreshes or Python scripts. Evidence’s Markdown-like syntax makes it easy to embed and format DataFrames within reports.
Streamlit DataFrames vs. Evidence Data Tables
| Feature | Streamlit | Evidence |
|---|---|---|
| Easy Markdown Syntax | ✖️ | ✔️ |
| SQL-Driven Tables | ✖️ | ✔️ |
| Interactive Sorting & Filtering | ✔️ | ✔️ |
| Python-Based DataFrames | ✔️ | ✖️ |
For interactive data visualization and reporting, Evidence’s <DataTable/> provides a more structured, SQL-native approach to data exploration.
Check out more features in the Evidence documentation.
