@@ -424,6 +424,25 @@ def test_constructor_multi_index(self):
424
424
df = DataFrame (index = mi , columns = mi )
425
425
assert pd .isna (df ).values .ravel ().all ()
426
426
427
+ def test_constructor_2d_index (self ):
428
+ # GH 25416
429
+ # handling of 2d index in construction
430
+ df = pd .DataFrame ([[1 ]], columns = [[1 ]], index = [1 , 2 ])
431
+ expected = pd .DataFrame (
432
+ [1 , 1 ],
433
+ index = pd .Int64Index ([1 , 2 ], dtype = "int64" ),
434
+ columns = pd .MultiIndex (levels = [[1 ]], codes = [[0 ]]),
435
+ )
436
+ tm .assert_frame_equal (df , expected )
437
+
438
+ df = pd .DataFrame ([[1 ]], columns = [[1 ]], index = [[1 , 2 ]])
439
+ expected = pd .DataFrame (
440
+ [1 , 1 ],
441
+ index = pd .MultiIndex (levels = [[1 , 2 ]], codes = [[0 , 1 ]]),
442
+ columns = pd .MultiIndex (levels = [[1 ]], codes = [[0 ]]),
443
+ )
444
+ tm .assert_frame_equal (df , expected )
445
+
427
446
def test_constructor_error_msgs (self ):
428
447
msg = "Empty data passed with indices specified."
429
448
# passing an empty array with columns specified.
0 commit comments