window
for filters> window {flags} (window_size)
--stride, -s {int}
: the number of rows to slide over between windows--remainder, -r
: yield last chunks even if they have fewer elements than sizewindow_size
: the size of each windowinput | output |
---|---|
list<any> | list<list<any>> |
A sliding window of two elements
> [1234] |window2
╭───┬───────────╮
│0│╭───┬───╮│
│││0│1││
│││1│2││
││╰───┴───╯│
│1│╭───┬───╮│
│││0│2││
│││1│3││
││╰───┴───╯│
│2│╭───┬───╮│
│││0│3││
│││1│4││
││╰───┴───╯│
╰───┴───────────╯
A sliding window of two elements, with a stride of 3
> [1, 2, 3, 4, 5, 6, 7, 8] |window2--stride3
╭───┬───────────╮
│0│╭───┬───╮│
│││0│1││
│││1│2││
││╰───┴───╯│
│1│╭───┬───╮│
│││0│4││
│││1│5││
││╰───┴───╯│
│2│╭───┬───╮│
│││0│7││
│││1│8││
││╰───┴───╯│
╰───┴───────────╯
A sliding window of equal stride that includes remainder. Equivalent to chunking
> [1, 2, 3, 4, 5] |window3--stride3--remainder
╭───┬───────────╮
│0│╭───┬───╮│
│││0│1││
│││1│2││
│││2│3││
││╰───┴───╯│
│1│╭───┬───╮│
│││0│4││
│││1│5││
││╰───┴───╯│
╰───┴───────────╯
Copyright © 2019–2023 The Nushell Project DevelopersLicensed under the MIT License.
https://www.nushell.sh/commands/docs/window.html