2019-11-26 20:47:34 +01:00
|
|
|
# histogram
|
|
|
|
|
|
|
|
Creates a new table with a histogram based on the column name passed in.
|
|
|
|
|
|
|
|
Syntax: `histogram <column_name> ...args`
|
|
|
|
|
|
|
|
### Parameters
|
|
|
|
|
|
|
|
* `<column-name>`: name of the column to graph by
|
|
|
|
* `args`: column name to give the histogram's frequency column
|
|
|
|
|
|
|
|
## Examples
|
|
|
|
|
|
|
|
Let's say we have this file `random_numers.csv` which contains 50 random numbers.
|
|
|
|
|
|
|
|
**Note**: The input doesn't have to be numbers it works on strings too. Try it out.
|
|
|
|
|
|
|
|
```shell
|
|
|
|
> open random_numbers.csv
|
2019-11-28 19:32:31 +01:00
|
|
|
open random_numbers2.csv
|
|
|
|
━━━━┯━━━━━━━━━━━━━━━━
|
2020-03-13 18:23:41 +01:00
|
|
|
# │ random numbers
|
2019-11-28 19:32:31 +01:00
|
|
|
────┼────────────────
|
2020-03-13 18:23:41 +01:00
|
|
|
0 │ 0
|
|
|
|
1 │ 5
|
|
|
|
2 │ 5
|
2019-11-26 20:47:34 +01:00
|
|
|
...
|
2020-03-13 18:23:41 +01:00
|
|
|
47 │ 0
|
|
|
|
48 │ 2
|
|
|
|
49 │ 4
|
2019-11-28 19:32:31 +01:00
|
|
|
━━━━┷━━━━━━━━━━━━━━━━
|
2019-11-26 20:47:34 +01:00
|
|
|
```
|
|
|
|
|
|
|
|
If we now want to see how often the different numbers were generated, we can use the `histogram` function:
|
|
|
|
|
|
|
|
```shell
|
2019-11-28 19:32:31 +01:00
|
|
|
> open random_numbers2.csv | histogram "random numbers"
|
|
|
|
━━━┯━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
2020-03-13 18:23:41 +01:00
|
|
|
# │ random numbers │ frequency
|
2019-11-28 19:32:31 +01:00
|
|
|
───┼────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────
|
2020-03-13 18:23:41 +01:00
|
|
|
0 │ 0 │ ****************************************************************************************************
|
|
|
|
1 │ 1 │ ******************************
|
|
|
|
2 │ 2 │ *************************************************************
|
|
|
|
3 │ 3 │ *********************************************************************
|
|
|
|
4 │ 4 │ *****************************************************
|
|
|
|
5 │ 5 │ *********************************************************************
|
2019-11-28 19:32:31 +01:00
|
|
|
━━━┷━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
2019-11-26 20:47:34 +01:00
|
|
|
```
|
|
|
|
|
2020-03-13 18:23:41 +01:00
|
|
|
We can also set the name of the second column or sort the table:
|
2019-11-26 20:47:34 +01:00
|
|
|
|
|
|
|
```shell
|
2019-11-28 19:32:31 +01:00
|
|
|
> open random_numbers2.csv | histogram "random numbers" probability
|
|
|
|
━━━┯━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
2020-03-13 18:23:41 +01:00
|
|
|
# │ random numbers │ probability
|
2019-11-28 19:32:31 +01:00
|
|
|
───┼────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────
|
2020-03-13 18:23:41 +01:00
|
|
|
0 │ 0 │ ****************************************************************************************************
|
|
|
|
1 │ 1 │ ******************************
|
|
|
|
2 │ 2 │ *************************************************************
|
|
|
|
3 │ 3 │ *********************************************************************
|
|
|
|
4 │ 4 │ *****************************************************
|
|
|
|
5 │ 5 │ *********************************************************************
|
2019-11-28 19:32:31 +01:00
|
|
|
━━━┷━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
|
|
|
2019-11-26 20:47:34 +01:00
|
|
|
```
|
|
|
|
|
|
|
|
```shell
|
2019-11-28 19:32:31 +01:00
|
|
|
> open random_numbers2.csv | histogram "random numbers" probability | sort-by probability
|
|
|
|
━━━┯━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
2020-03-13 18:23:41 +01:00
|
|
|
# │ random numbers │ probability
|
2019-11-28 19:32:31 +01:00
|
|
|
───┼────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────
|
2020-03-13 18:23:41 +01:00
|
|
|
0 │ 1 │ ******************************
|
|
|
|
1 │ 4 │ *****************************************************
|
|
|
|
2 │ 2 │ *************************************************************
|
|
|
|
3 │ 3 │ *********************************************************************
|
|
|
|
4 │ 5 │ *********************************************************************
|
|
|
|
5 │ 0 │ ****************************************************************************************************
|
2019-11-28 19:32:31 +01:00
|
|
|
━━━┷━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
|
|
|
2019-11-26 20:47:34 +01:00
|
|
|
```
|