def test_where_notstartswith_cs(self): df = create_df() df["C"] = ["hi", "HI there", "today", "what", "this"] w = Wrap(df) w = w.where("C !startswith_cs \"hi\"") self.assertListEqual(["HI there", "today", "what", "this"], list(w.df["C"]))
def test_where_equiv(self): df = create_df() df["O"] = [-1, 1, -1, 3, -1] w = Wrap(df) w = w.where("(B == O)") self.assertListEqual([1, 3], list(w.df["B"]))
def test_where_or(self): df = create_df() w = Wrap(df) w = w.where("(B >= 3) or (B < 1)") self.assertListEqual([0, 3, 4], list(w.df["B"]))
def test_where_and(self): df = create_df() w = Wrap(df) w = w.where("(B > 1) and (B < 4)") self.assertListEqual([2, 3], list(w.df["B"]))
def test_where(self): df = create_df() w = Wrap(df) w = w.where("B > 2") self.assertListEqual([3, 4], list(w.df["B"]))
def test_where_contains(self): df = create_df() df["C"] = ["hi", "HI there", "today", "what", "this"] w = Wrap(df) w = w.where("C contains \"hi\"") self.assertListEqual(["hi", "HI there", "this"], list(w.df["C"]))
def test_where_datetime(self): df = create_df() w = Wrap(df) w = w.where("D >= \"2009-01-06\"") self.assertListEqual([3, 4], list(w.df["B"]))