Skip to content

Commit 6e7f9bc

Browse files
committed
feat: Add missed boolean methods
oops
1 parent 8975189 commit 6e7f9bc

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

narwhals/_plan/dummy.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
from narwhals._plan.temporal import ExprDateTimeNamespace
4040
from narwhals._plan.typing import ExprT, Ns
4141
from narwhals.typing import (
42+
ClosedInterval,
4243
FillNullStrategy,
4344
NativeSeries,
4445
NumericLiteral,
@@ -376,6 +377,52 @@ def map_batches(
376377
).to_function_expr(self._ir)
377378
)
378379

380+
def any(self) -> Self:
381+
return self._from_ir(boolean.Any().to_function_expr(self._ir))
382+
383+
def all(self) -> Self:
384+
return self._from_ir(boolean.All().to_function_expr(self._ir))
385+
386+
def is_duplicated(self) -> Self:
387+
return self._from_ir(boolean.IsDuplicated().to_function_expr(self._ir))
388+
389+
def is_finite(self) -> Self:
390+
return self._from_ir(boolean.IsFinite().to_function_expr(self._ir))
391+
392+
def is_nan(self) -> Self:
393+
return self._from_ir(boolean.IsNan().to_function_expr(self._ir))
394+
395+
def is_null(self) -> Self:
396+
return self._from_ir(boolean.IsNull().to_function_expr(self._ir))
397+
398+
def is_first_distinct(self) -> Self:
399+
return self._from_ir(boolean.IsFirstDistinct().to_function_expr(self._ir))
400+
401+
def is_last_distinct(self) -> Self:
402+
return self._from_ir(boolean.IsLastDistinct().to_function_expr(self._ir))
403+
404+
def is_unique(self) -> Self:
405+
return self._from_ir(boolean.IsUnique().to_function_expr(self._ir))
406+
407+
def is_between(
408+
self,
409+
lower_bound: IntoExpr,
410+
upper_bound: IntoExpr,
411+
closed: ClosedInterval = "both",
412+
) -> Self:
413+
it = parse.parse_into_seq_of_expr_ir(lower_bound, upper_bound)
414+
return self._from_ir(
415+
boolean.IsBetween(closed=closed).to_function_expr(self._ir, *it)
416+
)
417+
418+
def is_in(self, other: t.Any) -> Self:
419+
msg = (
420+
"There's some special handling of iterables that I'm not sure on:\n"
421+
"https://github.com/narwhals-dev/narwhals/blob/8975189cb2459f129017cf833075b28ec3d4dfa8/narwhals/expr.py#L1176-L1184"
422+
)
423+
raise NotImplementedError(msg)
424+
return self._from_ir(boolean.IsIn().to_function_expr(self._ir))
425+
379426
def __eq__(self, other: IntoExpr) -> Self: # type: ignore[override]
380427
op = ops.Eq()
381428
rhs = parse.parse_into_expr_ir(other, str_as_lit=True)

0 commit comments

Comments
 (0)