We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 7c8c8c8 commit e4afa45Copy full SHA for e4afa45
pandas/tests/frame/test_constructors.py
@@ -424,6 +424,25 @@ def test_constructor_multi_index(self):
424
df = DataFrame(index=mi, columns=mi)
425
assert pd.isna(df).values.ravel().all()
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
440
441
+ index=pd.MultiIndex(levels=[[1, 2]], codes=[[0, 1]]),
442
443
444
445
446
def test_constructor_error_msgs(self):
447
msg = "Empty data passed with indices specified."
448
# passing an empty array with columns specified.
0 commit comments