mirror of
https://github.com/nushell/nushell.git
synced 2025-01-11 16:58:41 +01:00
update histogram, nth documentation
This commit is contained in:
parent
5406450c42
commit
7db3c69984
@ -17,156 +17,64 @@ Let's say we have this file `random_numers.csv` which contains 50 random numbers
|
|||||||
|
|
||||||
```shell
|
```shell
|
||||||
> open random_numbers.csv
|
> open random_numbers.csv
|
||||||
━━━━┯━━━━━━━━━━━━━━━
|
open random_numbers2.csv
|
||||||
# │ random number
|
━━━━┯━━━━━━━━━━━━━━━━
|
||||||
────┼───────────────
|
# │ random numbers
|
||||||
0 │ 87
|
────┼────────────────
|
||||||
1 │ 46
|
0 │ 0
|
||||||
2 │ 39
|
1 │ 5
|
||||||
|
2 │ 5
|
||||||
...
|
...
|
||||||
|
47 │ 0
|
||||||
47 │ 94
|
48 │ 2
|
||||||
48 │ 61
|
49 │ 4
|
||||||
49 │ 67
|
━━━━┷━━━━━━━━━━━━━━━━
|
||||||
━━━━┷━━━━━━━━━━━━━━━
|
|
||||||
```
|
```
|
||||||
|
|
||||||
If we now want to see how often the different numbers were generated, we can use the `histogram` function:
|
If we now want to see how often the different numbers were generated, we can use the `histogram` function:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
> open random_numbers.csv | histogram "random number"
|
> open random_numbers2.csv | histogram "random numbers"
|
||||||
━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
━━━┯━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||||
# │ random number │ frecuency
|
# │ random numbers │ frequency
|
||||||
────┼───────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────
|
───┼────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────
|
||||||
0 │ 10 │ *************************
|
0 │ 0 │ ****************************************************************************************************
|
||||||
1 │ 14 │ **************************************************
|
1 │ 1 │ ******************************
|
||||||
2 │ 17 │ *************************
|
2 │ 2 │ *************************************************************
|
||||||
3 │ 22 │ *************************
|
3 │ 3 │ *********************************************************************
|
||||||
4 │ 24 │ *************************
|
4 │ 4 │ *****************************************************
|
||||||
5 │ 28 │ *************************
|
5 │ 5 │ *********************************************************************
|
||||||
6 │ 29 │ *************************
|
━━━┷━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||||
7 │ 31 │ *************************
|
|
||||||
8 │ 37 │ *************************
|
|
||||||
9 │ 38 │ *************************
|
|
||||||
10 │ 39 │ *************************
|
|
||||||
11 │ 45 │ *************************
|
|
||||||
12 │ 46 │ ***************************************************************************
|
|
||||||
13 │ 49 │ *************************
|
|
||||||
14 │ 5 │ *************************
|
|
||||||
15 │ 51 │ ***************************************************************************
|
|
||||||
16 │ 52 │ *************************
|
|
||||||
17 │ 55 │ *************************
|
|
||||||
18 │ 56 │ **************************************************
|
|
||||||
19 │ 60 │ *************************
|
|
||||||
20 │ 61 │ **************************************************
|
|
||||||
21 │ 64 │ *************************
|
|
||||||
22 │ 65 │ *************************
|
|
||||||
23 │ 67 │ **************************************************
|
|
||||||
24 │ 68 │ *************************
|
|
||||||
25 │ 73 │ *************************
|
|
||||||
26 │ 80 │ **************************************************
|
|
||||||
27 │ 82 │ *************************
|
|
||||||
28 │ 86 │ ****************************************************************************************************
|
|
||||||
29 │ 87 │ **************************************************
|
|
||||||
30 │ 88 │ *************************
|
|
||||||
31 │ 89 │ *************************
|
|
||||||
32 │ 9 │ *************************
|
|
||||||
33 │ 92 │ *************************
|
|
||||||
34 │ 94 │ *************************
|
|
||||||
35 │ 96 │ *************************
|
|
||||||
36 │ 99 │ *************************
|
|
||||||
━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
||||||
```
|
```
|
||||||
|
|
||||||
We can also set the name of the second column or sort the table:
|
We can also set the name of the second column or sort the table:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
> open random_numbers.csv | histogram "random number" probability
|
> open random_numbers2.csv | histogram "random numbers" probability
|
||||||
━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
━━━┯━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||||
# │ random number │ probability
|
# │ random numbers │ probability
|
||||||
────┼───────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────
|
───┼────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────
|
||||||
0 │ 10 │ *************************
|
0 │ 0 │ ****************************************************************************************************
|
||||||
1 │ 14 │ **************************************************
|
1 │ 1 │ ******************************
|
||||||
2 │ 17 │ *************************
|
2 │ 2 │ *************************************************************
|
||||||
3 │ 22 │ *************************
|
3 │ 3 │ *********************************************************************
|
||||||
4 │ 24 │ *************************
|
4 │ 4 │ *****************************************************
|
||||||
5 │ 28 │ *************************
|
5 │ 5 │ *********************************************************************
|
||||||
6 │ 29 │ *************************
|
━━━┷━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||||
7 │ 31 │ *************************
|
|
||||||
8 │ 37 │ *************************
|
|
||||||
9 │ 38 │ *************************
|
|
||||||
10 │ 39 │ *************************
|
|
||||||
11 │ 45 │ *************************
|
|
||||||
12 │ 46 │ ***************************************************************************
|
|
||||||
13 │ 49 │ *************************
|
|
||||||
14 │ 5 │ *************************
|
|
||||||
15 │ 51 │ ***************************************************************************
|
|
||||||
16 │ 52 │ *************************
|
|
||||||
17 │ 55 │ *************************
|
|
||||||
18 │ 56 │ **************************************************
|
|
||||||
19 │ 60 │ *************************
|
|
||||||
20 │ 61 │ **************************************************
|
|
||||||
21 │ 64 │ *************************
|
|
||||||
22 │ 65 │ *************************
|
|
||||||
23 │ 67 │ **************************************************
|
|
||||||
24 │ 68 │ *************************
|
|
||||||
25 │ 73 │ *************************
|
|
||||||
26 │ 80 │ **************************************************
|
|
||||||
27 │ 82 │ *************************
|
|
||||||
28 │ 86 │ ****************************************************************************************************
|
|
||||||
29 │ 87 │ **************************************************
|
|
||||||
30 │ 88 │ *************************
|
|
||||||
31 │ 89 │ *************************
|
|
||||||
32 │ 9 │ *************************
|
|
||||||
33 │ 92 │ *************************
|
|
||||||
34 │ 94 │ *************************
|
|
||||||
35 │ 96 │ *************************
|
|
||||||
36 │ 99 │ *************************
|
|
||||||
━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
||||||
```
|
```
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
> open random_numbers.csv | histogram "random number" probability | sort-by probability
|
> open random_numbers2.csv | histogram "random numbers" probability | sort-by probability
|
||||||
━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
━━━┯━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||||
# │ random number │ probability
|
# │ random numbers │ probability
|
||||||
────┼───────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────
|
───┼────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────
|
||||||
0 │ 10 │ *************************
|
0 │ 1 │ ******************************
|
||||||
1 │ 17 │ *************************
|
1 │ 4 │ *****************************************************
|
||||||
2 │ 22 │ *************************
|
2 │ 2 │ *************************************************************
|
||||||
3 │ 24 │ *************************
|
3 │ 3 │ *********************************************************************
|
||||||
4 │ 28 │ *************************
|
4 │ 5 │ *********************************************************************
|
||||||
5 │ 29 │ *************************
|
5 │ 0 │ ****************************************************************************************************
|
||||||
6 │ 31 │ *************************
|
━━━┷━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||||
7 │ 37 │ *************************
|
|
||||||
8 │ 38 │ *************************
|
|
||||||
9 │ 39 │ *************************
|
|
||||||
10 │ 45 │ *************************
|
|
||||||
11 │ 49 │ *************************
|
|
||||||
12 │ 5 │ *************************
|
|
||||||
13 │ 52 │ *************************
|
|
||||||
14 │ 55 │ *************************
|
|
||||||
15 │ 60 │ *************************
|
|
||||||
16 │ 64 │ *************************
|
|
||||||
17 │ 65 │ *************************
|
|
||||||
18 │ 68 │ *************************
|
|
||||||
19 │ 73 │ *************************
|
|
||||||
20 │ 82 │ *************************
|
|
||||||
21 │ 88 │ *************************
|
|
||||||
22 │ 89 │ *************************
|
|
||||||
23 │ 9 │ *************************
|
|
||||||
24 │ 92 │ *************************
|
|
||||||
25 │ 94 │ *************************
|
|
||||||
26 │ 96 │ *************************
|
|
||||||
27 │ 99 │ *************************
|
|
||||||
28 │ 14 │ **************************************************
|
|
||||||
29 │ 56 │ **************************************************
|
|
||||||
30 │ 61 │ **************************************************
|
|
||||||
31 │ 67 │ **************************************************
|
|
||||||
32 │ 80 │ **************************************************
|
|
||||||
33 │ 87 │ **************************************************
|
|
||||||
34 │ 46 │ ***************************************************************************
|
|
||||||
35 │ 51 │ ***************************************************************************
|
|
||||||
36 │ 86 │ ****************************************************************************************************
|
|
||||||
━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
||||||
```
|
```
|
@ -3,10 +3,13 @@
|
|||||||
This command returns the nth row of a table, starting from 0.
|
This command returns the nth row of a table, starting from 0.
|
||||||
If the number given is less than 0 or more than the number of rows, nothing is returned.
|
If the number given is less than 0 or more than the number of rows, nothing is returned.
|
||||||
|
|
||||||
## Usage
|
### Usage
|
||||||
```shell
|
```shell
|
||||||
> [input-command] | nth [row-number]
|
> [input-command] | nth <row number> ...args
|
||||||
```
|
```
|
||||||
|
### Parameters:
|
||||||
|
* `<row number>` the number of the row to return
|
||||||
|
* `args`: Optionally return more rows
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
```shell
|
```shell
|
||||||
@ -21,11 +24,19 @@ If the number given is less than 0 or more than the number of rows, nothing is r
|
|||||||
━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━
|
━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━
|
||||||
|
|
||||||
> ls | nth 0
|
> ls | nth 0
|
||||||
━━━━━━━━━━━━┯━━━━━━┯━━━━━━━━━━┯━━━━━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━
|
━━━┯━━━━━━━━━━━━┯━━━━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━
|
||||||
name │ type │ readonly │ size │ accessed │ modified
|
# │ name │ type │ readonly │ size │ accessed │ modified
|
||||||
────────────┼──────┼──────────┼────────┼───────────────┼───────────────
|
───┼────────────┼───────────┼──────────┼────────┼───────────────┼───────────────
|
||||||
Cargo.toml │ File │ │ 239 B │ 2 minutes ago │ 2 minutes ago
|
0 │ Cargo.toml │ File │ │ 239 B │ 2 minutes ago │ 2 minutes ago
|
||||||
━━━━━━━━━━━━┷━━━━━━┷━━━━━━━━━━┷━━━━━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━
|
━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━
|
||||||
|
|
||||||
|
> ls | nth 0 2
|
||||||
|
━━━┯━━━━━━━━━━━━┯━━━━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━
|
||||||
|
# │ name │ type │ readonly │ size │ accessed │ modified
|
||||||
|
───┼────────────┼───────────┼──────────┼────────┼───────────────┼───────────────
|
||||||
|
0 │ Cargo.toml │ File │ │ 239 B │ 2 minutes ago │ 2 minutes ago
|
||||||
|
2 │ .gitignore │ File │ │ 19 B │ 2 minutes ago │ 2 minutes ago
|
||||||
|
━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━
|
||||||
|
|
||||||
> ls | nth 5
|
> ls | nth 5
|
||||||
```
|
```
|
Loading…
Reference in New Issue
Block a user