dtale
dtale copied to clipboard
Customization of column analysis for categorical column
Hi Team, Thank you very much for such a beautiful package. I want to highlight the rows, which start and end with spaces. currently I am only able to get the count of those rows through categorical column analysis. Is there any way to highlight those, please help me out. Thanks in advance.
@BALADEV-1234 just trying to get some clarity. So you have some categorical data, strings I assume, and you want to filter down to the rows which have categories that start and end with spaces? If this is the case here's an example of how to do this.
I input this dataframe:
pd.DataFrame([
{'desc': ' foo', 'count': 10, 'cum_pct': 15},
{'desc': 'bar', 'count': 6, 'cum_pct': 40},
{'desc': 'baz', 'count': 3, 'cum_pct': 75},
{'desc': 'biz ', 'count': 1, 'cum_pct': 100}
])
And then you can go to the "Custom Filter" popup and input the following filter:
`desc`.str.startswith(' ') or `desc`.str.endswith(' ')
Hope this helps, let me know how it goes.
@aschonfeld, Although filtering is useful, it is often visually helpful to be able to simply highlight some rows in an unfiltered grid. Excel conditional formatting is a pretty commonly used feature, but it's ruleset and UI for this are cumbersome. I think it would be awesome to be able to use a pandas query expression to apply a selectable highlight color to the resulting rows in the main table. I'm not not implying you re-create excel, but having something like this would save exporting it to analyze in a different tool. Ideally, the main grid would allow you to apply a highlight color of user choice for multiple (SHIFT+CLICK), possibly discontiguous rows (via CTRL+Click), but also have a form like this let you apply a user-chosen highlight color to the filtered rows like your form above. If the form was reused but instead offered a "Apply Highlight" button, it would make for a maybe a low-risk implementation?
@lcorrigan I know you've wiped your hands of D-Tale but I'd still love your input on this new filter highlighting functionality I'm building. So right now theres two ways you can turn it on.
-
toggling the highlighter icon on any active filter listed at the top of the screen https://user-images.githubusercontent.com/11547371/215193679-8c930a8d-6572-4954-aed1-30b7a5713936.mov
-
Toggling the "Highlight Filtered Rows" checkbox on the filter popup or side panel: https://user-images.githubusercontent.com/11547371/215195044-12cfecde-4c14-4ebc-859a-ffc7f2d6ba15.mov
I'm also working on updating the code so that you can have filter highlighting turned on by default. By doing things like:
import pandas as pd
import dtale
dtale.show(pd.DataFrame([1,2,3,4,5]), highlight_filter=True)
or by specifying highlight_filter = True
in the [show]
section of thje global configuration file described here
Let me know what you think? Thanks
Hi @aschonfeld, that looks pretty good to me, and covers the use-case in an easy-to-use way. Nice job.
@BALADEV-1234 just released v2.12.0 with this functionality, let me know if you hit any issues