File tree Expand file tree Collapse file tree 3 files changed +17
-5
lines changed Expand file tree Collapse file tree 3 files changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -170,6 +170,8 @@ Bug Fixes
170170 a datetimelike (:issue: `6152 `)
171171 - Fixed a stack overflow bug in ``query ``/``eval `` during lexicographic
172172 string comparisons (:issue: `6155 `).
173+ - Fixed a bug in ``query `` where the index of a single-element ``Series `` was
174+ being thrown away (:issue: `6148 `).
173175
174176pandas 0.13.0
175177-------------
Original file line number Diff line number Diff line change @@ -81,16 +81,12 @@ def wrapper(terms):
8181 return _align_core_single_unary_op (terms [0 ])
8282
8383 term_values = (term .value for term in terms )
84+
8485 # only scalars or indexes
8586 if all (isinstance (term .value , pd .Index ) or term .isscalar for term in
8687 terms ):
8788 return np .result_type (* term_values ), None
8889
89- # single element ndarrays
90- all_has_size = all (hasattr (term .value , 'size' ) for term in terms )
91- if all_has_size and all (term .value .size == 1 for term in terms ):
92- return np .result_type (* term_values ), None
93-
9490 # no pandas objects
9591 if not _any_pandas_objects (terms ):
9692 return np .result_type (* term_values ), None
Original file line number Diff line number Diff line change @@ -12860,6 +12860,20 @@ def test_query_lex_compare_strings(self):
1286012860 for parser , engine in product (PARSERS , ENGINES ):
1286112861 yield self .check_query_lex_compare_strings , parser , engine
1286212862
12863+ def check_query_single_element_booleans (self , parser , engine ):
12864+ tm .skip_if_no_ne (engine )
12865+ columns = 'bid' , 'bidsize' , 'ask' , 'asksize'
12866+ data = np .random .randint (2 , size = (1 , len (columns ))).astype (bool )
12867+ df = DataFrame (data , columns = columns )
12868+ res = df .query ('bid & ask' , engine = engine , parser = parser )
12869+ expected = df [df .bid & df .ask ]
12870+ assert_frame_equal (res , expected )
12871+
12872+ def test_query_single_element_booleans (self ):
12873+ for parser , engine in product (PARSERS , ENGINES ):
12874+ yield self .check_query_single_element_booleans , parser , engine
12875+
12876+
1286312877class TestDataFrameEvalNumExprPandas (tm .TestCase ):
1286412878
1286512879 @classmethod
You can’t perform that action at this time.
0 commit comments