Initializing playground…
← Back to roadmap

✂️ element-wise operations — Interactive Playground

Scalar transforms applied independently to each element — mirrors pandas.Series.clip(), .abs(), and .round().
Edit any code block below and press ▶ Run (or Ctrl+Enter) to execute it live in your browser.

1 · clip: bound values to a range

clip(series, { lower, upper }) replaces any value below lower with lower, and any value above upper with upper. Pass only one bound to clip from one side only. Mirrors pandas.Series.clip().

TypeScript
Click ▶ Run to execute
Ctrl+Enter to run · Tab to indent

2 · clip on a DataFrame

dataFrameClip(df, { lower, upper }) applies the same clipping to every numeric column. Mirrors pandas.DataFrame.clip().

TypeScript
Click ▶ Run to execute
Ctrl+Enter to run · Tab to indent

3 · seriesAbs: absolute value

seriesAbs(series) returns a new Series where every element is replaced by its absolute value. Mirrors pandas.Series.abs().

TypeScript
Click ▶ Run to execute
Ctrl+Enter to run · Tab to indent

4 · dataFrameAbs: absolute values for all columns

dataFrameAbs(df) applies abs() column-by-column. Mirrors pandas.DataFrame.abs().

TypeScript
Click ▶ Run to execute
Ctrl+Enter to run · Tab to indent

5 · seriesRound: round to N decimal places

seriesRound(series, { decimals }) rounds each value to the given number of decimal places (default 0). Negative decimals rounds to the left of the decimal point (e.g. -1 rounds to the nearest 10). Mirrors pandas.Series.round().

TypeScript
Click ▶ Run to execute
Ctrl+Enter to run · Tab to indent

6 · dataFrameRound: round all columns

dataFrameRound(df, { decimals }) rounds every numeric column of a DataFrame. Mirrors pandas.DataFrame.round().

TypeScript
Click ▶ Run to execute
Ctrl+Enter to run · Tab to indent

7 · Missing values pass through

All three operations propagate null and NaN unchanged — consistent with pandas' behaviour.

TypeScript
Click ▶ Run to execute
Ctrl+Enter to run · Tab to indent

API Reference

All element-wise operations return new Series/DataFrame instances — the originals are never mutated. Missing values (null, NaN) pass through unchanged.

// Series clip
clip(series, {
  lower?: number,   // minimum bound (default: -Infinity)
  upper?: number,   // maximum bound (default: +Infinity)
}): Series<number>

// DataFrame clip
dataFrameClip(df, { lower?, upper? }): DataFrame

// Series absolute value
seriesAbs(series): Series<number>

// DataFrame absolute value
dataFrameAbs(df): DataFrame

// Series round
seriesRound(series, {
  decimals?: number,  // default 0 — negative rounds left of decimal
}): Series<number>

// DataFrame round
dataFrameRound(df, { decimals? }): DataFrame