Bin
Bin groups the numbers in a column into ranges and gives each row a bin number, starting at 1. Choose equal counts, equal widths, standard deviations or your own cut points. Replace the column or add a new one. Every method except Equal width can also label each range.
Group prices into three bands
Manual Input holds six products. Bin splits price into three bins with equal numbers of rows, keeps the original column and adds a label.
Bin interactive example
Loading interactive example…
The live example needs a desktop screen. The result it produces is shown here, and the explanation and settings below work on any screen.
| price | product | price_bin | price_bin_label |
|---|---|---|---|
| 1 | Pen | 1 | Q1 of 3 |
| 5 | Mug | 1 | Q1 of 3 |
| 9 | Lamp | 2 | Q2 of 3 |
| 12 | Book | 2 | Q2 of 3 |
| 20 | Bag | 3 | Q3 of 3 |
| 33 | Chair | 3 | Q3 of 3 |
- Look at the preview. Pen and Mug are in bin 1, Lamp and Book in bin 2, Bag and Chair in bin 3. The new columns are
price_binandprice_bin_label. - Change Bins to
2. Each bin now holds three products, and the labels readQ1 of 2andQ2 of 2. - Uncheck Separate Columns. The bin number now replaces the value in
price.
When to use
Use Bin to turn exact numbers into bands, such as low, medium and high prices or age groups. To rescale numbers without grouping them, use Scale. To convert text categories, use Encode.
Inputs and outputs
Inputs
1 port- InRequired
Accepts: Tables, Geospatial data.
Accepts one connection on this port.
Outputs
1 port- Out
Configure the block
- Columns
The binning method for each numeric column. None leaves a column unchanged. Equal count puts roughly the same number of rows in each bin. Equal width splits the value range into equal intervals. Standard deviation groups values into six bands by their distance from the mean. Manual cuts at the break points you enter.
- Equal count all numeric
Sets every numeric column to Equal count.
- Equal width all numeric
Sets every numeric column to Equal width.
- Std dev all numeric
Sets every numeric column to Standard deviation.
- Clear all
Sets every column back to None.
- Group By
Optional categorical columns that bin each group independently, e.g. revenue deciles within each country. Leave empty to bin over all rows together. Manual breaks are absolute and ignore grouping.
- Bins
Number of bins for equal-count and equal-width methods. Standard deviation always uses six bands and ignores this setting. Bins number from 1 upward and nulls stay null. Equal count, equal width and standard deviation compute their cut points per group; manual breaks are absolute and ignore Group By.
Default:
4- Breaks
Comma-separated cut points for manual binning, in increasing order. N breaks produce N + 1 bins.
- Separate Columns
Write bin numbers to new <column>_bin columns instead of replacing the source.
Default:
true- Add Label
Append a <column>_bin_label text column describing each bin's range. Equal width adds no label.
Default:
false
Bin FAQs
- Why does Standard deviation ignore Bins?
- Standard deviation always uses six fixed bands around the mean: below -2, -2 to -1, -1 to 0, 0 to 1, 1 to 2 and above 2 standard deviations. Bins applies only to Equal count and Equal width.
- Which methods can add a label?
- Add Label works with Equal count, Standard deviation and Manual. Equal width adds no label column.
- What happens to missing values?
- Nulls stay null, whichever method you choose. The row stays in the output.
Prepare your data. Build it in Strata.
Strata opens in your browser, with no account.