Spaces:
Sleeping
Sleeping
Update app.py
Browse files703 unmodified lines704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733703 unmodified linesdf_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, "")# Apply the text color function to the DataFramestyled_df = df_builder_pivot.style.applymap(lambda trust_driver: text_color_trust_driver(trust_driver), subset=["Trust Driver®"])# Convert the styled DataFrame to HTML for Gradio displaystyled_html = styled_df.render()# Use Gradio's `gr.HTML` to render the table with colored textgr.Interface(fn=lambda: styled_html,inputs=[],outputs="html").launch()#df_builder_pivot = df_builder_pivot.sort_values(# by=["%"], ascending=[False]#)703 unmodified lines704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737703 unmodified linesdf_builder_pivot = df_builder_pivot.sort_values(by=["Trust Driver®", "%"], ascending=[True, False])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 color map to the Trust Driver® columnstyled_df = df_builder_pivot.style.applymap(apply_colors, subset=["Trust Driver®"])# Convert the styled DataFrame to HTML for Gradio displaystyled_html = styled_df.to_html()# Now use Gradio's HTML block to display the table with the colorsimport gradio as grinterface = gr.Interface(fn=lambda: styled_html,inputs=[],outputs=gr.HTML(),)interface.launch()#df_builder_pivot = df_builder_pivot.sort_values(# by=["%"], ascending=[False]#)
app.py+22-18