Skip to content

Commit

Permalink
Implement $has_nulls()
Browse files Browse the repository at this point in the history
  • Loading branch information
etiennebacher committed Jun 5, 2024
1 parent 14e8547 commit 116ba46
Show file tree
Hide file tree
Showing 6 changed files with 220 additions and 162 deletions.
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Polars R Package (development version)

### New features

- New method `$has_nulls()` (#1133).

## Polars R Package 0.17.0

### Breaking changes
Expand Down
16 changes: 16 additions & 0 deletions R/expr__expr.R
Original file line number Diff line number Diff line change
Expand Up @@ -3742,3 +3742,19 @@ Expr_qcut = function(
unwrap("in $qcut():")
}
}

#' Check whether the expression contains one or more null values
#'
#' @return Expr
#'
#' @examples
#' df = pl$DataFrame(
#' a = c(NA, 1, NA),
#' b = c(1, NA, 2),
#' c = c(1, 2, 3)
#' )
#'
#' df$select(pl$all()$has_nulls())
Expr_has_nulls = function() {
self$null_count() > 0
}
2 changes: 1 addition & 1 deletion R/expr__name.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ ExprName_keep = function() {
}

# TODO: this method is broken after <https://github.com/pola-rs/r-polars/pull/1104>, so not documented
#' @noRd
#' Map alias of expression with an R function
#'
#' Rename the output of an expression by mapping a function over the root name.
Expand All @@ -69,6 +68,7 @@ ExprName_keep = function() {
#' df$select(
#' pl$col("var1")$alias("foobar")$name$map(\(x) paste0("new_", x))
#' )
#' @noRd
ExprName_map = function(fun) {
if (
!polars_options()$no_messages &&
Expand Down
23 changes: 23 additions & 0 deletions man/Expr_has_nulls.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 116ba46

Please sign in to comment.