Skip to content

Missing Data

fillna — fill missing values

Replace null / NaN values with a constant.

Fill all columns

with raw as clean
    fillna 0
with raw as clean
    fillna "unknown"

Fill specific columns

Use an indented block to fill different columns with different values:

with raw as clean
    fillna
        price = 0
        name = "unknown"
        region = "N/A"

Or use comma-separated syntax:

with raw as clean
    fillna price 0, name "unknown", region "N/A"

Unquoted per-column fill values are column references:

with sales
    med_rev = median(revenue)
        by product
    fillna revenue med_rev

Only the listed columns are filled. All other columns are unchanged.


dropna — drop rows with missing values

Drop rows with any missing value

with raw as complete
    dropna

Drop rows where specific columns are missing

Only drop a row if any of the listed columns are null:

with raw as complete
    dropna price, quantity
with raw as complete
    dropna customer_id, product_id, date