From 5c6044ad300de5ec4889df216963ad72bbfabcf1 Mon Sep 17 00:00:00 2001 From: anjakefala Date: Wed, 24 Jul 2024 22:19:35 -0700 Subject: [PATCH] [docs] add options to TypeSheet.md --- visidata/guides/TypesSheet.md | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/visidata/guides/TypesSheet.md b/visidata/guides/TypesSheet.md index 1eaf8514b..3a79b76c8 100644 --- a/visidata/guides/TypesSheet.md +++ b/visidata/guides/TypesSheet.md @@ -1,6 +1,6 @@ # Types -Columns usually begin as untyped (`anytype`), but can be set. +Columns usually begin as untyped (`anytype`), but can be set to specific types. - {help.commands.type-any} - {help.commands.type-currency} @@ -10,4 +10,34 @@ Columns usually begin as untyped (`anytype`), but can be set. - {help.commands.type-len} - {help.commands.type-string} -*Note*: `float` uses the decimal separator; `currency` removes non-numeric characters and parses as float; `date` parses dates into ISO8601 format; `len` formats the cell value to the length of the content. \ No newline at end of file +## Type formatting + +VisiData pre-set defaults for formatting types: + +- `currency` removes non-numeric characters and parses the remainder as `float`. +- `date` parses dates into date object (shown as ISO8601). +- `vlen` formats the cell value to the length of the content +- `float` uses the decimal seperator, keeping two significant digits. + +Change float precision with: +- {help.commands.setcol-precision-less} +- {help.commands.setcol-precision-more} + +To change the default fmtstr for a type: + +- {help.options.disp_currency_fmt} +- {help.options.color_currency_neg} +- {help.options.disp_date_fmt} +- {help.options.disp_float_fmt} +- {help.options.disp_int_fmt} + + +## Importance of typing + +Certain commands behave differently depending on how the column is typed. + +Grouping by a numeric column in a Frequency table can result in numeric range binning. Grouping by a string results in categorical binning. + +Un-typed columns (`anytype`) often default to `string`-like behaviour. Errors when working with numerical or datetime data is often due to values being considered as strings. + +For example. [:code]addcol-expr col1+col2[/] results in a concatenation of the two columns when they are `anytype`, and addition when they are numerical.