|
39 | 39 | from narwhals._plan.temporal import ExprDateTimeNamespace |
40 | 40 | from narwhals._plan.typing import ExprT, Ns |
41 | 41 | from narwhals.typing import ( |
| 42 | + ClosedInterval, |
42 | 43 | FillNullStrategy, |
43 | 44 | NativeSeries, |
44 | 45 | NumericLiteral, |
@@ -376,6 +377,52 @@ def map_batches( |
376 | 377 | ).to_function_expr(self._ir) |
377 | 378 | ) |
378 | 379 |
|
| 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 | + |
379 | 426 | def __eq__(self, other: IntoExpr) -> Self: # type: ignore[override] |
380 | 427 | op = ops.Eq() |
381 | 428 | rhs = parse.parse_into_expr_ir(other, str_as_lit=True) |
|
0 commit comments