@@ -154,6 +154,12 @@ def test_constructor(self, datetime_series):
154
154
with pytest .raises (NotImplementedError , match = msg ):
155
155
Series (m )
156
156
157
+ def test_constructor_index_ndim_gt_1_raises (self ):
158
+ # GH#18579
159
+ df = DataFrame ([[1 , 2 ], [3 , 4 ], [5 , 6 ]], index = [3 , 6 , 9 ])
160
+ with pytest .raises (ValueError , match = "Index data must be 1-dimensional" ):
161
+ Series ([1 , 3 , 2 ], index = df )
162
+
157
163
@pytest .mark .parametrize ("input_class" , [list , dict , OrderedDict ])
158
164
def test_constructor_empty (self , input_class ):
159
165
with tm .assert_produces_warning (FutureWarning ):
@@ -276,6 +282,15 @@ def test_constructor_list_like(self):
276
282
result = Series (obj , index = [0 , 1 , 2 ])
277
283
tm .assert_series_equal (result , expected )
278
284
285
+ def test_constructor_boolean_index (self ):
286
+ # GH#18579
287
+ s1 = Series ([1 , 2 , 3 ], index = [4 , 5 , 6 ])
288
+
289
+ index = s1 == 2
290
+ result = Series ([1 , 3 , 2 ], index = index )
291
+ expected = Series ([1 , 3 , 2 ], index = [False , True , False ])
292
+ tm .assert_series_equal (result , expected )
293
+
279
294
@pytest .mark .parametrize ("dtype" , ["bool" , "int32" , "int64" , "float64" ])
280
295
def test_constructor_index_dtype (self , dtype ):
281
296
# GH 17088
0 commit comments