@@ -12603,6 +12603,7 @@ def setUpClass(cls):
12603
12603
cls .parser = 'pandas'
12604
12604
cls .frame = _frame .copy ()
12605
12605
12606
+
12606
12607
class TestDataFrameQueryPythonPython (TestDataFrameQueryNumExprPython ):
12607
12608
12608
12609
@classmethod
@@ -12611,6 +12612,7 @@ def setUpClass(cls):
12611
12612
cls .engine = cls .parser = 'python'
12612
12613
cls .frame = _frame .copy ()
12613
12614
12615
+
12614
12616
PARSERS = 'python' , 'pandas'
12615
12617
ENGINES = 'python' , 'numexpr'
12616
12618
@@ -12742,6 +12744,34 @@ def test_object_array_eq_ne(self):
12742
12744
for parser , engine in product (PARSERS , ENGINES ):
12743
12745
yield self .check_object_array_eq_ne , parser , engine
12744
12746
12747
+ def check_query_with_nested_strings (self , parser , engine ):
12748
+ skip_if_no_ne (engine )
12749
+ skip_if_no_pandas_parser (parser )
12750
+ from pandas .compat import StringIO
12751
+ raw = """id event timestamp
12752
+ 1 "page 1 load" 1/1/2014 0:00:01
12753
+ 1 "page 1 exit" 1/1/2014 0:00:31
12754
+ 2 "page 2 load" 1/1/2014 0:01:01
12755
+ 2 "page 2 exit" 1/1/2014 0:01:31
12756
+ 3 "page 3 load" 1/1/2014 0:02:01
12757
+ 3 "page 3 exit" 1/1/2014 0:02:31
12758
+ 4 "page 1 load" 2/1/2014 1:00:01
12759
+ 4 "page 1 exit" 2/1/2014 1:00:31
12760
+ 5 "page 2 load" 2/1/2014 1:01:01
12761
+ 5 "page 2 exit" 2/1/2014 1:01:31
12762
+ 6 "page 3 load" 2/1/2014 1:02:01
12763
+ 6 "page 3 exit" 2/1/2014 1:02:31
12764
+ """
12765
+ df = pd .read_csv (StringIO (raw ), sep = r'\s{2,}' ,
12766
+ parse_dates = ['timestamp' ])
12767
+ expected = df [df .event == '"page 1 load"' ]
12768
+ res = df .query ("""'"page 1 load"' in event""" , parser = parser ,
12769
+ engine = engine )
12770
+ tm .assert_frame_equal (expected , res )
12771
+
12772
+ def test_query_with_nested_string (self ):
12773
+ for parser , engine in product (PARSERS , ENGINES ):
12774
+ yield self .check_query_with_nested_strings , parser , engine
12745
12775
12746
12776
class TestDataFrameEvalNumExprPandas (tm .TestCase ):
12747
12777
@@ -12779,6 +12809,7 @@ def setUpClass(cls):
12779
12809
cls .parser = 'python'
12780
12810
skip_if_no_ne ()
12781
12811
12812
+
12782
12813
class TestDataFrameEvalPythonPandas (TestDataFrameEvalNumExprPandas ):
12783
12814
12784
12815
@classmethod
@@ -12787,13 +12818,15 @@ def setUpClass(cls):
12787
12818
cls .engine = 'python'
12788
12819
cls .parser = 'pandas'
12789
12820
12821
+
12790
12822
class TestDataFrameEvalPythonPython (TestDataFrameEvalNumExprPython ):
12791
12823
12792
12824
@classmethod
12793
12825
def setUpClass (cls ):
12794
12826
super (TestDataFrameEvalPythonPython , cls ).tearDownClass ()
12795
12827
cls .engine = cls .parser = 'python'
12796
12828
12829
+
12797
12830
if __name__ == '__main__' :
12798
12831
nose .runmodule (argv = [__file__ , '-vvs' , '-x' , '--pdb' , '--pdb-failure' ],
12799
12832
exit = False )
0 commit comments