I have here a challenge, hoping you guys could support me. Suppose you have the following frame
import pandas as pd
import numpy as np
import streamlit as st
from st_aggrid import AgGrid
testFrame=pd.DataFrame({"col1":["Albert","Mike","John","Laura"],"col2":["New York - Violation of Rule", "London", "Berlin - Violation of Rule", "Sao Paolo"]})
grid_return=AgGrid(testFrame, editable=True)
General=grid_return["data"]
What I would like to achieve is that if a column contains the string “Violation of Rule” the cell color backround color should be white and the text color in red, something like this
I’d like to achieve this, since I have a large frame and having a color-coding approach will help my colleagues to find the important cells faster
Hi Caroline,
please apologies if I did not explain it well. Let me give you a short explanation in bullet points
I read an excel file via file_uploader
I I check some columns for some rules, and if rules are violated I add " - Violation of Rule in the same cell
I change the static frame to a dynamic one via AgGrid
The user can now see the dynamic frame and change data
The issue is that the frame is quite big and I would like to support the user by color coding only the cells which contain the string “- Violation of Rule” and that the frame remains dynamic
Thanks for clarifying! In that case, it sounds like you want AgGrid to update the formatting rather than changing the formatting of the dataframe. I’ll move this question to the AgGrid section of the forum so that the AgGrid experts can chime in
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.