Home Explore Blog CI



nushell

1st chunk of `commands/docs/histogram.md`
aa26693c4f557b3d52b0729e69580c4d78680758fa6f7bad0000000100000bb4
---
title: histogram
categories: |
  chart
version: 0.104.0
chart: |
  Creates a new table with a histogram based on the column name passed in.
usage: |
  Creates a new table with a histogram based on the column name passed in.
editLink: false
contributors: false
---
<!-- This file is automatically generated. Please edit the command in https://github.com/nushell/nushell instead. -->

# `histogram` for [chart](/commands/categories/chart.md)

<div class='command-title'>Creates a new table with a histogram based on the column name passed in.</div>

## Signature

```> histogram {flags} (column-name) (frequency-column-name)```

## Flags

 -  `--percentage-type, -t {string}`: percentage calculate method, can be 'normalize' or 'relative', in 'normalize', defaults to be 'normalize'

## Parameters

 -  `column-name`: Column name to calc frequency, no need to provide if input is a list.
 -  `frequency-column-name`: Histogram's frequency column, default to be frequency column output.


## Input/output types:

| input     | output |
| --------- | ------ |
| list\<any\> | table  |
## Examples

Compute a histogram of file types
```nu
> ls | histogram type

```

Compute a histogram for the types of files, with frequency column named freq
```nu
> ls | histogram type freq

```

Compute a histogram for a list of numbers
```nu
> [1 2 1] | histogram
╭────┬────────┬────────┬───────────┬─────────────┬────────────────────────────────────────────────────────────────────╮
│  # │ value  │ count  │ quantile  │ percentage  │                             frequency                              │
├────┼────────┼────────┼───────────┼─────────────┼────────────────────────────────────────────────────────────────────┤
│  0 │      1 │      2 │      0.67 │ 66.67%      │ ****************************************************************** │
│  1 │      2 │      1 │      0.33 │ 33.33%      │ *********************************                                  │
╰────┴────────┴────────┴───────────┴─────────────┴────────────────────────────────────────────────────────────────────╯

```

Compute a histogram for a list of numbers, and percentage is based on the maximum value
```nu
> [1 2 3 1 1 1 2 2 1 1] | histogram --percentage-type relative

```

Title: histogram
Summary
The `histogram` command creates a new table with a histogram based on the specified column. It can calculate frequency and percentage, with options for normalization or relative calculation. It can be used with tables or lists, and the frequency column name can be customized.