Skip to content

Commit

Permalink
[guides] Add a FrequencyTable Guide (#2534)
Browse files Browse the repository at this point in the history
Co-authored-by: anjakefala <[email protected]>
  • Loading branch information
thejud and anjakefala authored Oct 7, 2024
1 parent c26d51d commit acdf5f7
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
2 changes: 1 addition & 1 deletion visidata/aggregators.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down
42 changes: 42 additions & 0 deletions visidata/guides/FrequencyTable.md
Original file line number Diff line number Diff line change
@@ -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}

0 comments on commit acdf5f7

Please sign in to comment.