Exemplo n.º 1
0
 def test_simple(self):
     f = pandassql.FilterGroup()
     b1 = pd.Series([0,1,1,1,0])
     b2 = pd.Series([0,1,1,1,0])
     f.add_filter(b1)
     f.add_filter(b2)
     res = f.reduce()
     assert tm.assert_almost_equal(res, b1)
Exemplo n.º 2
0
 def test_simple_or(self):
     f = pandassql.FilterGroup(type="OR")
     b1 = pd.Series([0,1,0,1,0])
     b2 = pd.Series([1,1,0,0,0])
     f.add_filter(b1)
     f.add_filter(b2)
     res = f.reduce()
     exp = pd.Series([1,1,0,1,0])
     assert tm.assert_almost_equal(res, exp)
Exemplo n.º 3
0
    def test_nested(self):
        f = pandassql.FilterGroup(type="OR")
        b1 = pd.Series([0,1,0,1,0])
        b2 = pd.Series([1,1,0,0,0])
        f.add_filter(b1)
        f.add_filter(b2)

        parent = pandassql.FilterGroup(type="AND")
        b3 = pd.Series([1,0,0,1,0])
        parent.add_filter(b3)
        parent.add_filter(f)

        res = parent.reduce()

        assert tm.assert_almost_equal(res, b3)

        sup = pandassql.FilterGroup(type="OR")
        b4 = pd.Series([1,1,0,0,1])
        sup.add_filter(parent)
        sup.add_filter(b4)

        res = sup.reduce()

        assert tm.assert_almost_equal(res, pd.Series([1,1,0,1,1]))