Spaces:
Sleeping
Sleeping
Update app.py
Browse files703 unmodified lines704705706707708709710711712713714715716707708709710711712713714715716717718719718719720721722723722724725726727728724725729730731728729730732733734735736737703 unmodified lines df_builder_pivot = df_builder_pivot.sort_values( by=["Trust Driver®", "%"], ascending=[True, False] ) def text_color_trust_driver(trust_driver): colors = { "Stability": "color: #42546C", "Development": "color: #D4B372", "Relationship": "color: #A94E4D", "Benefit": "color: #5C8084", "Vision": "color: #C98F69", "Competence": "color: #7B92A7", } return colors.get(trust_driver, "") colors = { "Stability": "color: #42546C", "Development": "color: #D4B372", "Relationship": "color: #A94E4D", "Benefit": "color: #5C8084", "Vision": "color: #C98F69", "Competence": "color: #7B92A7", } def apply_colors(val): return colors.get(val, "") # Apply the text color function to the DataFrame styled_df = df_builder_pivot.style.applymap(lambda trust_driver: text_color_trust_driver(trust_driver), subset=["Trust Driver®"]) # Apply the color map to the Trust Driver® column styled_df = df_builder_pivot.style.applymap(apply_colors, subset=["Trust Driver®"]) # Convert the styled DataFrame to HTML for Gradio display styled_html = styled_df.render() styled_html = styled_df.to_html() # Now use Gradio's HTML block to display the table with the colors import gradio as gr # Use Gradio's `gr.HTML` to render the table with colored text gr.Interface( interface = gr.Interface( fn=lambda: styled_html, inputs=[], outputs="html" ).launch() outputs=gr.HTML(), ) interface.launch() #df_builder_pivot = df_builder_pivot.sort_values( # by=["%"], ascending=[False] #)app.py+22-18