mirror of
https://github.com/nushell/nushell.git
synced 2024-12-24 07:59:21 +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
|
||||
> open random_numbers.csv
|
||||
━━━━┯━━━━━━━━━━━━━━━
|
||||
# │ random number
|
||||
────┼───────────────
|
||||
0 │ 87
|
||||
1 │ 46
|
||||
2 │ 39
|
||||
|
||||
open random_numbers2.csv
|
||||
━━━━┯━━━━━━━━━━━━━━━━
|
||||
# │ random numbers
|
||||
────┼────────────────
|
||||
0 │ 0
|
||||
1 │ 5
|
||||
2 │ 5
|
||||
...
|
||||
|
||||
47 │ 94
|
||||
48 │ 61
|
||||
49 │ 67
|
||||
━━━━┷━━━━━━━━━━━━━━━
|
||||
47 │ 0
|
||||
48 │ 2
|
||||
49 │ 4
|
||||
━━━━┷━━━━━━━━━━━━━━━━
|
||||
```
|
||||
|
||||
If we now want to see how often the different numbers were generated, we can use the `histogram` function:
|
||||
|
||||
```shell
|
||||
> open random_numbers.csv | histogram "random number"
|
||||
━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
# │ random number │ frecuency
|
||||
────┼───────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────
|
||||
0 │ 10 │ *************************
|
||||
1 │ 14 │ **************************************************
|
||||
2 │ 17 │ *************************
|
||||
3 │ 22 │ *************************
|
||||
4 │ 24 │ *************************
|
||||
5 │ 28 │ *************************
|
||||
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 │ *************************
|
||||
━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
> open random_numbers2.csv | histogram "random numbers"
|
||||
━━━┯━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
# │ random numbers │ frequency
|
||||
───┼────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────
|
||||
0 │ 0 │ ****************************************************************************************************
|
||||
1 │ 1 │ ******************************
|
||||
2 │ 2 │ *************************************************************
|
||||
3 │ 3 │ *********************************************************************
|
||||
4 │ 4 │ *****************************************************
|
||||
5 │ 5 │ *********************************************************************
|
||||
━━━┷━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
```
|
||||
|
||||
We can also set the name of the second column or sort the table:
|
||||
|
||||
```shell
|
||||
> open random_numbers.csv | histogram "random number" probability
|
||||
━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
# │ random number │ probability
|
||||
────┼───────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────
|
||||
0 │ 10 │ *************************
|
||||
1 │ 14 │ **************************************************
|
||||
2 │ 17 │ *************************
|
||||
3 │ 22 │ *************************
|
||||
4 │ 24 │ *************************
|
||||
5 │ 28 │ *************************
|
||||
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 │ *************************
|
||||
━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
> open random_numbers2.csv | histogram "random numbers" probability
|
||||
━━━┯━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
# │ random numbers │ probability
|
||||
───┼────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────
|
||||
0 │ 0 │ ****************************************************************************************************
|
||||
1 │ 1 │ ******************************
|
||||
2 │ 2 │ *************************************************************
|
||||
3 │ 3 │ *********************************************************************
|
||||
4 │ 4 │ *****************************************************
|
||||
5 │ 5 │ *********************************************************************
|
||||
━━━┷━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
|
||||
```
|
||||
|
||||
```shell
|
||||
> open random_numbers.csv | histogram "random number" probability | sort-by probability
|
||||
━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
# │ random number │ probability
|
||||
────┼───────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────
|
||||
0 │ 10 │ *************************
|
||||
1 │ 17 │ *************************
|
||||
2 │ 22 │ *************************
|
||||
3 │ 24 │ *************************
|
||||
4 │ 28 │ *************************
|
||||
5 │ 29 │ *************************
|
||||
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 │ ****************************************************************************************************
|
||||
━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
> open random_numbers2.csv | histogram "random numbers" probability | sort-by probability
|
||||
━━━┯━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
# │ random numbers │ probability
|
||||
───┼────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────
|
||||
0 │ 1 │ ******************************
|
||||
1 │ 4 │ *****************************************************
|
||||
2 │ 2 │ *************************************************************
|
||||
3 │ 3 │ *********************************************************************
|
||||
4 │ 5 │ *********************************************************************
|
||||
5 │ 0 │ ****************************************************************************************************
|
||||
━━━┷━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
|
||||
```
|
@ -3,10 +3,13 @@
|
||||
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.
|
||||
|
||||
## Usage
|
||||
### Usage
|
||||
```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
|
||||
```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
|
||||
━━━━━━━━━━━━┯━━━━━━┯━━━━━━━━━━┯━━━━━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━
|
||||
name │ type │ readonly │ size │ accessed │ modified
|
||||
────────────┼──────┼──────────┼────────┼───────────────┼───────────────
|
||||
Cargo.toml │ File │ │ 239 B │ 2 minutes ago │ 2 minutes ago
|
||||
━━━━━━━━━━━━┷━━━━━━┷━━━━━━━━━━┷━━━━━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━
|
||||
━━━┯━━━━━━━━━━━━┯━━━━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━
|
||||
# │ name │ type │ readonly │ size │ accessed │ modified
|
||||
───┼────────────┼───────────┼──────────┼────────┼───────────────┼───────────────
|
||||
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
|
||||
```
|
Loading…
Reference in New Issue
Block a user