i want to add st.badge in a colum of st.dataframe
To upload files, please first save the app
import streamlit as st
import pandas as pd
import numpy as np
# Create sample data
df = pd.DataFrame({
'Name': ['John', 'Alice', 'Bob', 'Carol'],
'Age': [25, 30, 35, 28],
'Status': ['Active', 'Inactive', 'Active', 'Active']
})
# Define column configuration for the Status column
st.title("Dataframe with Badge Column")
st.dataframe(
df,
column_config={
"Status": st.column_config.Column(
"Status",
help="User account status",
# Define badge colors based on status
display_badge={
"Active": "success",
"Inactive": "danger"
}
)
},
hide_index=True
)
# Add explanation
st.markdown("""
### About the Badge Colors
- 🟢 Green badge indicates an **Active** status
- 🔴 Red badge indicates an **Inactive** status
""")
Hi! I can help you with any questions about Streamlit and Python. What would you like to know?