From 49cebecb88c012b1c46792d0ba039573ab129a7e Mon Sep 17 00:00:00 2001 From: Gourav Kumar Date: Sun, 22 May 2022 17:39:42 +0530 Subject: [PATCH] __and__, __or__ in Series --- fincal/core.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/fincal/core.py b/fincal/core.py index b1dd1c6..4027574 100644 --- a/fincal/core.py +++ b/fincal/core.py @@ -221,7 +221,23 @@ class Series(UserList): if isinstance(other, Series): return Series([j != other[i] for i, j in enumerate(self)], "bool") - return Series([i == other for i in self.data], "bool") + return Series([i != other for i in self.data], "bool") + + def __and__(self, other): + other = self._comparison_validator(other) + + if isinstance(other, Series): + return Series([j and other[i] for i, j in enumerate(self)], "bool") + + return Series([i and other for i in self.data], "bool") + + def __or__(self, other): + other = self._comparison_validator(other) + + if isinstance(other, Series): + return Series([j or other[i] for i, j in enumerate(self)], "bool") + + return Series([i or other for i in self.data], "bool") def _math_validator(self, other):