diff --git a/buckaroo/polars_buckaroo.py b/buckaroo/polars_buckaroo.py index 8a164a8f8..c620b39c8 100644 --- a/buckaroo/polars_buckaroo.py +++ b/buckaroo/polars_buckaroo.py @@ -15,12 +15,27 @@ from .dataflow.dataflow import Sampling from .dataflow.autocleaning import PandasAutocleaning from .dataflow.widget_extension_utils import configure_buckaroo +from .styling_helpers import obj_, pinned_histogram, pinned_filtered_histogram class PLSampling(Sampling): pre_limit = False serialize_limit = 1_000_000 -local_analysis_klasses = list(PL_ANALYSIS_V2) + [DefaultSummaryStatsStyling, DefaultMainStyling] + +class PolarsMainStyling(DefaultMainStyling): + """Polars default styling — adds an optional ``?filtered_histogram`` + pinned row alongside the bare raw ``histogram``. The ``?`` prefix + means JS only renders the row when at least one column has the + ``filtered_histogram`` key in ``merged_sd``, i.e. when a search + filter is active. Polars materialises the filt scope cheaply, so + showing both raw and filtered histograms side-by-side is the + default; xorq skips computing filtered_histogram (#829) and pandas + keeps the original ``[dtype, histogram]`` layout.""" + + pinned_rows = [obj_('dtype'), pinned_histogram(), pinned_filtered_histogram()] + + +local_analysis_klasses = list(PL_ANALYSIS_V2) + [DefaultSummaryStatsStyling, PolarsMainStyling] class PolarsAutocleaning(PandasAutocleaning): diff --git a/buckaroo/styling_helpers.py b/buckaroo/styling_helpers.py index 0052cad3a..26c316c0b 100644 --- a/buckaroo/styling_helpers.py +++ b/buckaroo/styling_helpers.py @@ -12,3 +12,6 @@ def inherit_(pkey): def pinned_histogram(): return {'primary_key_val': 'histogram', 'displayer_args': {'displayer': 'histogram'}} + +def pinned_filtered_histogram(): + return {'primary_key_val': '?filtered_histogram', 'displayer_args': {'displayer': 'histogram'}}