File tree 3 files changed +17
-5
lines changed
3 files changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -170,6 +170,8 @@ Bug Fixes
170
170
a datetimelike (:issue: `6152 `)
171
171
- Fixed a stack overflow bug in ``query ``/``eval `` during lexicographic
172
172
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 `).
173
175
174
176
pandas 0.13.0
175
177
-------------
Original file line number Diff line number Diff line change @@ -81,16 +81,12 @@ def wrapper(terms):
81
81
return _align_core_single_unary_op (terms [0 ])
82
82
83
83
term_values = (term .value for term in terms )
84
+
84
85
# only scalars or indexes
85
86
if all (isinstance (term .value , pd .Index ) or term .isscalar for term in
86
87
terms ):
87
88
return np .result_type (* term_values ), None
88
89
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
-
94
90
# no pandas objects
95
91
if not _any_pandas_objects (terms ):
96
92
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):
12860
12860
for parser , engine in product (PARSERS , ENGINES ):
12861
12861
yield self .check_query_lex_compare_strings , parser , engine
12862
12862
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
+
12863
12877
class TestDataFrameEvalNumExprPandas (tm .TestCase ):
12864
12878
12865
12879
@classmethod
You can’t perform that action at this time.
0 commit comments