I am working on a Data Profiling project.
I want to change the background color of empty white spaces in options of the multiselect widget.
When the user chooses a certain option from a radio widget, the code gets the unique values of a pandas column and shows them in a multiselect widget.
I want the change the background color of the spaces because sometimes the same values have leading/trailing white spaces, and I want the user to be able to see them in order to choose the values without the trailing/leading whitespaces.
Example of what I need:
Is that, or any other approach to handle leading/trailing whitespaces, achievable in any way?
yes actually, I want to show the quality of the data in columns.
So in case of categorical data, a list of the values existing in the column must be shown, in order to choose the correct values that we want to compare the column’s values against.
In the example above, we would select “Value A” and “Value B” that are without the trailing/leading spaces (as the only values that should exist in this column). Then the algorithm would check this rule, and get back with the rate of correct values against wrong ones.
Th wrong ones are the values with spaces, or are different values than the chosen.
If the solution as in the above photo is not possible, then maybe changing the color of the values with the spaces to red? Is that possible?
One option, though it’s not a general-purpose solution to formatting:
def formatter (x):
return str(x).replace(' ','⬛')
st.selectbox('Choose',[' This is an option','This is an option','This is an option ', 'This is an option '], index=0, format_func=formatter)