Skip to content

Drop nulls (missing values)

Source code

Description

Drop all rows that contain nulls (which correspond to NA in R).

Usage

<DataFrame>$drop_nulls(subset = NULL)

Arguments

subset A character vector with the names of the column(s) for which nulls are considered. If NULL (default), use all columns.

Value

DataFrame

Examples

library("polars")

tmp = mtcars
tmp[1:3, "mpg"] = NA
tmp[4, "hp"] = NA
tmp = as_polars_df(tmp)

# number of rows in `tmp` before dropping nulls
tmp$height
#> [1] 32
tmp$drop_nulls()$height
#> [1] 28
tmp$drop_nulls("mpg")$height
#> [1] 29
tmp$drop_nulls(c("mpg", "hp"))$height
#> [1] 28