Loading tsb runtime…
← Back to playground index

Missing-value operations

isna / notna — detect missing values in scalars, Series, and DataFrames.
ffill / bfill — propagate the last (or next) valid value to fill gaps.
Mirrors pd.isna(), Series.ffill(), and DataFrame.bfill() from pandas.

1 · isna / notna on scalars

Returns true / false for individual values. null, undefined, and NaN are all considered "missing".

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

2 · isna on a Series

When passed a Series, isna returns a boolean Series of the same length — true where values are missing.

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

3 · isna on a DataFrame

Returns a DataFrame of booleans with the same shape — one column per original column, true where missing.

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

4 · Forward-fill (ffillSeries)

Propagates the last valid value forward to fill gaps. Leading nulls that have no preceding value remain null. Use the optional limit to cap consecutive fills.

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

5 · Backward-fill (bfillSeries)

Propagates the next valid value backward to fill gaps. Trailing nulls that have no following value remain null.

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

6 · DataFrame forward-fill & backward-fill

dataFrameFfill and dataFrameBfill apply fill column-wise by default (axis=0). Pass axis: 1 to fill row-wise across columns.

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

API Reference

// Module-level missing-value detection
isna(value: Scalar): boolean
isna(value: Series): Series<boolean>
isna(value: DataFrame): DataFrame

notna(value: Scalar): boolean
notna(value: Series): Series<boolean>
notna(value: DataFrame): DataFrame

// Aliases
isnull(...)  // same as isna
notnull(...) // same as notna

// Series forward / backward fill
ffillSeries(series, options?: { limit?: number | null }): Series
bfillSeries(series, options?: { limit?: number | null }): Series

// DataFrame forward / backward fill
dataFrameFfill(df, options?: {
  limit?: number | null,   // max consecutive fills (default: no limit)
  axis?: 0 | 1 | "index" | "columns",  // default 0 (column-wise)
}): DataFrame

dataFrameBfill(df, options?: {
  limit?: number | null,
  axis?: 0 | 1 | "index" | "columns",
}): DataFrame