Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions pandas/tests/frame/test_constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,25 @@ def test_constructor_multi_index(self):
df = DataFrame(index=mi, columns=mi)
assert pd.isna(df).values.ravel().all()

def test_constructor_2d_index(self):
# GH 25416
# handling of 2d index in construction
df = pd.DataFrame([[1]], columns=[[1]], index=[1, 2])
expected = pd.DataFrame(
[1, 1],
index=pd.Int64Index([1, 2], dtype="int64"),
columns=pd.MultiIndex(levels=[[1]], codes=[[0]]),
)
tm.assert_frame_equal(df, expected)

df = pd.DataFrame([[1]], columns=[[1]], index=[[1, 2]])
expected = pd.DataFrame(
[1, 1],
index=pd.MultiIndex(levels=[[1, 2]], codes=[[0, 1]]),
columns=pd.MultiIndex(levels=[[1]], codes=[[0]]),
)
tm.assert_frame_equal(df, expected)

def test_constructor_error_msgs(self):
msg = "Empty data passed with indices specified."
# passing an empty array with columns specified.
Expand Down