nushell/crates/nu-std/std
Eric Hodel 3dfe1a4f0e
group-by now returns a table instead of a record (#10848)
# Description

Previously `group-by` returned a record containing each group as a
column. This data layout is hard to work with for some tasks because you
have to further manipulate the result to do things like determine the
number of items in each group, or the number of groups. `transpose` will
turn the record returned by `group-by` into a table, but this is
expensive when `group-by` is run on a large input.

In a discussion with @fdncred [several
workarounds](https://github.com/nushell/nushell/discussions/10462) to
common tasks were discussed, but they seem unsatisfying in general.

Now when `group-by --to-table` is used a table is returned with the
columns "groups" and "items" making it easier to do things like count
the number of groups (`| length`) or count the number of items in each
group (`| each {|g| $g.items | length`)

# User-Facing Changes

* `group-by` returns a `table` with "group" and "items" columns instead
of a `record` with one column per group name

# Tests + Formatting

Tests for `group-by` were updated

# After Submitting

* No breaking changes were made. The new `--to-table` switch should be
added automatically to the [`group-by`
documentation](https://www.nushell.sh/commands/docs/group-by.html)
2023-10-28 14:15:14 -05:00
..
assert.nu improve assertion error messages in std assert (#10551) 2023-10-01 16:40:24 +02:00
dirs.nu dirs goto: update current ring slot before leaving it. (#10706) 2023-10-13 06:46:51 -05:00
dt.nu std dt datetime-diff: fix uninitialized field ref when borrowing (#10466) 2023-09-24 10:53:56 +02:00
formats.nu add to ndjson and to jsonl to the standard library (#10519) 2023-10-02 11:50:07 +02:00
help.nu differentiating between --x and --x: bool (#10456) 2023-09-23 10:20:48 +02:00
input.nu Command to get individual keys (#9453) 2023-07-03 10:23:44 -05:00
iter.nu Add long options for filters (#10641) 2023-10-08 13:12:46 +02:00
log.nu remove underline from std NU_LOG_FORMAT (#10604) 2023-10-04 13:30:49 -05:00
math.nu move math constants to standard library (#9678) 2023-09-05 19:32:31 +02:00
mod.nu expand paths and split PATH in std path add (#10710) 2023-10-25 16:43:27 +02:00
testing.nu group-by now returns a table instead of a record (#10848) 2023-10-28 14:15:14 -05:00
xml.nu Improve type hovers (#9515) 2023-06-29 05:19:48 +12:00