SheetXL - v0.8.0-beta.9+sites.210.e2d420901
    Preparing search index...

    Frequency distribution results for a range.

    Provides pandas-like value_counts() functionality.

    interface IFrequency {
        getExtent(value: Scalar): IRange.Coords | null;
        getFrequency(value: Scalar): number;
        getTotalCount(): number;
        getUniqueCount(): number;
        getUniqueValues(): IterableIterator<Scalar>;
        getValueCounts(
            options?: { descending?: boolean; sortBy?: "value" | "frequency" },
        ): IterableIterator<[Scalar, number]>;
        getVisitedCount(): number;
        isTruncated(): boolean;
    }
    Index
    • Returns the bounding box of a value's occurrences, in the coordinates of the scanned grid.

      Parameters

      • value: Scalar

        The value to look up

      Returns IRange.Coords | null

      The smallest rectangle containing every occurrence, or null when the value was not found, is blank, or the frequencies were merged from several ranges (no single grid).

      Tracked by the same scan that counts, so it costs nothing extra. A box whose cell count equals getFrequency is a contiguous block — the value lives in exactly that rectangle; a larger box means the occurrences are scattered within it.

    • Returns the frequency (occurrence count) of a specific value.

      Parameters

      • value: Scalar

        The value to look up

      Returns number

      Number of times the value appears, or 0 if not found

    • Total count of values in the range (respecting options).

      Returns number

    • Total count of distinct values in the range (respecting options).

      Returns number

    • Returns an iterator of distinct values found (respecting options).

      Returns IterableIterator<Scalar>

      Iterator can be consumed only once.

      Example: Data: ["Red", "Red", "Red", "Blue", "Blue", "Green"] getUniqueValues() -> Iterator("Red", "Blue", "Green")

    • Returns unique values with their frequencies as an iterator.

      Parameters

      • Optionaloptions: { descending?: boolean; sortBy?: "value" | "frequency" }
        • Optionaldescending?: boolean

          Sort direction

        • OptionalsortBy?: "value" | "frequency"

          How to sort results

      Returns IterableIterator<[Scalar, number]>

      Iterator of [value, count] tuples, sorted by frequency (descending) by default

      • First item is the mode (most frequent value)
      • Values of equal count hold the order they were first seen
      • Matches pandas value_counts() behavior
      • Iterator can be consumed only once
      // Get mode (most common)
      const [mode, count] = stats.getValueCounts().next().value;

      // Get top 3
      const top3 = Array.from(stats.getValueCounts()).slice(0, 3);

      // All values for dropdown
      const all = Array.from(stats.getValueCounts());
    • Number of cells visited in the source range iteration.

      Returns number

      May be less than total range size if limit was hit.

    • Indicates if results were truncated due to the limit option.

      Returns boolean

      When true, there may be additional distinct values that weren't counted. This is a convenience method (visitedCount < totalCount)