From acdf5f722073c8ae928ec85722aac387ea5ee79a Mon Sep 17 00:00:00 2001 From: thejud Date: Sun, 6 Oct 2024 18:05:40 -0700 Subject: [PATCH] [guides] Add a FrequencyTable Guide (#2534) Co-authored-by: anjakefala --- visidata/aggregators.py | 2 +- visidata/guides/FrequencyTable.md | 42 +++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 visidata/guides/FrequencyTable.md diff --git a/visidata/aggregators.py b/visidata/aggregators.py index f0242b1ac..a468d93e0 100644 --- a/visidata/aggregators.py +++ b/visidata/aggregators.py @@ -288,7 +288,7 @@ def _fmt_aggr_summary(match, row, trigger_key): vd.warning(f'aggregator does not exist: {aggr}') return aggrs -Sheet.addCommand('+', 'aggregate-col', 'addAggregators([cursorCol], chooseAggregators())', 'Add aggregator to current column') +Sheet.addCommand('+', 'aggregate-col', 'addAggregators([cursorCol], chooseAggregators())', 'add aggregator to current column') Sheet.addCommand('z+', 'memo-aggregate', 'cursorCol.memo_aggregate(chooseAggregators(), selectedRows or rows)', 'memo result of aggregator over values in selected rows for current column') ColumnsSheet.addCommand('g+', 'aggregate-cols', 'addAggregators(selectedRows or source[0].nonKeyVisibleCols, chooseAggregators())', 'add aggregators to selected source columns') diff --git a/visidata/guides/FrequencyTable.md b/visidata/guides/FrequencyTable.md new file mode 100644 index 000000000..4b321833b --- /dev/null +++ b/visidata/guides/FrequencyTable.md @@ -0,0 +1,42 @@ +# Frequency Tables are how you GROUP BY + +Frequency Tables group rows into bins by column value, and includes summary columns for source columns with aggregators. + +Set `--numeric-binning` to bin numeric rows into ranges instead of discrete values. + +- {help.commands.freq_col} + +- {help.commands.freq_keys} + +- {help.commands.freq_summary} + +## Aggregators + +A **Frequency Table** contains a summary columns for each aggregator added to a source column. +These aggregators need to be added before creating the Frequency Table. +Examples of aggregators include min, max, sum, distinct, count, and list. + +- {help.commands.aggregate-col} + +Note: set an appropriate type for the aggregator target column, for example {help.commands.type_float}. + +## Explore the data + +Dive into a group to see the underlying row(s) using the **Frequency Table**: + +- {help.commands.open_row} +- {help.commands.dive_selected} + +Select a group to select all of its underlying rows in the source sheet. + +## Using Split Panes with Frequency Tables + +Press `Shift+Z` to open a split pane, and then `Shift+F` to create a **Frequency Table**. The **Frequency Table** will automatically open in the other pane. + +See the `SplitpanesGuide` for more. + +#### Options + +- {help.options.disp_histogram} +- {help.options.histogram_bins} +- {help.options.numeric_binning}