[Python] How I can color a st.data_editor cell based on a condition

Discussão em 'Python' iniciado por Stack, Junho 5, 2025.

  1. Stack

    Stack Membro Participativo

    I using streamlit st.data_editor, I have this dataframe :

    import streamlit as st
    import pandas as pd

    df = pd.DataFrame(
    [
    {"command": "test 1", "rating": 4, "is_widget": True},
    {"command": "test 2", "rating": 5, "is_widget": False},
    {"command": "test 3", "rating": 3, "is_widget": True},
    ]
    )
    edited_df = st.data_editor(df)


    is there a way please to color a pecific cell based on a condition, I want to colorize in yellow the cell (in the rating col) when the value <2.

    thanks for your help

    Continue reading...

Compartilhe esta Página