Skip to content

Commit

Permalink
feat(python): allow eq,ne,lt etc (#5995)
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 committed Jan 2, 2023
1 parent 935e04b commit e3d0e83
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
18 changes: 18 additions & 0 deletions py-polars/polars/internals/expr/expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,24 @@ def __lt__(self, other: Any) -> Expr:
def __gt__(self, other: Any) -> Expr:
return wrap_expr(self._pyexpr.gt(self._to_expr(other)._pyexpr))

def ge(self, other: Any) -> Expr:
return self.__ge__(other)

def le(self, other: Any) -> Expr:
return self.__le__(other)

def eq(self, other: Any) -> Expr:
return self.__eq__(other)

def ne(self, other: Any) -> Expr:
return self.__ne__(other)

def lt(self, other: Any) -> Expr:
return self.__lt__(other)

def gt(self, other: Any) -> Expr:
return self.__gt__(other)

def __neg__(self) -> Expr:
return pli.lit(0) - self

Expand Down
15 changes: 15 additions & 0 deletions py-polars/polars/internals/series/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,21 @@ def __ge__(self, other: Any) -> Series:
def __le__(self, other: Any) -> Series:
return self._comp(other, "lt_eq")

def le(self, other: Any) -> Series:
return self.__le__(other)

def eq(self, other: Any) -> Series:
return self.__eq__(other)

def ne(self, other: Any) -> Series:
return self.__ne__(other)

def lt(self, other: Any) -> Series:
return self.__lt__(other)

def gt(self, other: Any) -> Series:
return self.__gt__(other)

def _arithmetic(self, other: Any, op_s: str, op_ffi: str) -> Series:
if isinstance(other, pli.Expr):
# expand pl.lit, pl.datetime, pl.duration Exprs to compatible Series
Expand Down

0 comments on commit e3d0e83

Please sign in to comment.