W3cubDocs

/Nushell

drop for filters

Remove items/rows from the end of the input list/table. Counterpart of `skip`. Opposite of `last`.

Signature

> drop {flags} (rows)

Parameters

  • rows: The number of items to remove

Input/output types:

input output
list<any> list<any>
table table

Examples

Remove the last item of a list

> [0,1,2,3] |drop
╭───┬───╮
00
11
22
╰───┴───╯

Remove zero item of a list

> [0,1,2,3] |drop0
╭───┬───╮
00
11
22
33
╰───┴───╯

Remove the last two items of a list

> [0,1,2,3] |drop2
╭───┬───╮
00
11
╰───┴───╯

Remove the last row in a table

> [[a, b]; [1, 2] [3, 4]] |drop1
╭───┬───┬───╮
# │ a │ b │
├───┼───┼───┤
012
╰───┴───┴───╯

Subcommands:

name type usage
drop column Builtin Remove N columns at the right-hand end of the input table. To remove columns by name, use reject.
drop nth Builtin Drop the selected rows.

Copyright © 2019–2023 The Nushell Project DevelopersLicensed under the MIT License.
https://www.nushell.sh/commands/docs/drop.html