Skip to content

Commit e3d0e83

Browse files
authored
feat(python): allow eq,ne,lt etc (#5995)
1 parent 935e04b commit e3d0e83

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

py-polars/polars/internals/expr/expr.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,24 @@ def __lt__(self, other: Any) -> Expr:
242242
def __gt__(self, other: Any) -> Expr:
243243
return wrap_expr(self._pyexpr.gt(self._to_expr(other)._pyexpr))
244244

245+
def ge(self, other: Any) -> Expr:
246+
return self.__ge__(other)
247+
248+
def le(self, other: Any) -> Expr:
249+
return self.__le__(other)
250+
251+
def eq(self, other: Any) -> Expr:
252+
return self.__eq__(other)
253+
254+
def ne(self, other: Any) -> Expr:
255+
return self.__ne__(other)
256+
257+
def lt(self, other: Any) -> Expr:
258+
return self.__lt__(other)
259+
260+
def gt(self, other: Any) -> Expr:
261+
return self.__gt__(other)
262+
245263
def __neg__(self) -> Expr:
246264
return pli.lit(0) - self
247265

py-polars/polars/internals/series/series.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,21 @@ def __ge__(self, other: Any) -> Series:
470470
def __le__(self, other: Any) -> Series:
471471
return self._comp(other, "lt_eq")
472472

473+
def le(self, other: Any) -> Series:
474+
return self.__le__(other)
475+
476+
def eq(self, other: Any) -> Series:
477+
return self.__eq__(other)
478+
479+
def ne(self, other: Any) -> Series:
480+
return self.__ne__(other)
481+
482+
def lt(self, other: Any) -> Series:
483+
return self.__lt__(other)
484+
485+
def gt(self, other: Any) -> Series:
486+
return self.__gt__(other)
487+
473488
def _arithmetic(self, other: Any, op_s: str, op_ffi: str) -> Series:
474489
if isinstance(other, pli.Expr):
475490
# expand pl.lit, pl.datetime, pl.duration Exprs to compatible Series

0 commit comments

Comments
 (0)