cutBinsToFrame(result, { data }) converts the output of
cut() or qcut() into a summary DataFrame with
one row per bin, showing the bin label, edges, count, and frequency.
import { cut, cutBinsToFrame, cutBinCounts, binEdges } from "tsb";
// Bin 20 random values into 4 equal-width bins
const data = Array.from({ length: 20 }, () => Math.random() * 100);
const result = cut(data, 4);
// Summary DataFrame: bin | left | right | count | frequency
const df = cutBinsToFrame(result, { data });
// Just the count dictionary
const counts = cutBinCounts(result);
// { "(0.0, 25.0]": 5, "(25.0, 50.0]": 6, ... }
// Just edges indexed by label
const edges = binEdges(result);
cut(data, bins) — bin values into equal-width binsqcut(data, bins) — bin values into quantile-based binscutBinsToFrame(result, { data }) — summary DataFramecutBinCounts(result) — label → count dictionarybinEdges(result) — edges DataFrame indexed by label