Skip to content

Commit 7ae07bd

Browse files
author
Marco Gorelli
committed
Add multiindex (named and unnamed) to test cases
1 parent c4f0786 commit 7ae07bd

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

pandas/tests/frame/test_explode.py

+30
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,36 @@ def test_usecase():
150150
dtype=object,
151151
).set_index("my_index"),
152152
),
153+
(
154+
pd.DataFrame(
155+
{
156+
"col": [[1, 2], [3, 4]],
157+
"other_col": ["a", "b"],
158+
"my_first_index": [0, 0],
159+
"my_second_index": [1, 1],
160+
}
161+
).set_index(["my_first_index", "my_second_index"]),
162+
pd.DataFrame(
163+
{
164+
"col": [1, 2, 3, 4],
165+
"other_col": ["a", "a", "b", "b"],
166+
"my_first_index": [0, 0, 0, 0],
167+
"my_second_index": [1, 1, 1, 1],
168+
},
169+
dtype=object,
170+
).set_index(["my_first_index", "my_second_index"]),
171+
),
172+
(
173+
pd.DataFrame(
174+
{"col": [[1, 2], [3, 4]], "other_col": ["a", "b"]},
175+
pd.MultiIndex.from_tuples([(0, 1), (0, 1)]),
176+
),
177+
pd.DataFrame(
178+
{"col": [1, 2, 3, 4], "other_col": ["a", "a", "b", "b"]},
179+
index=pd.MultiIndex.from_tuples([(0, 1), (0, 1), (0, 1), (0, 1)]),
180+
dtype=object,
181+
),
182+
),
153183
],
154184
)
155185
def test_duplicate_index(df, expected):

0 commit comments

Comments
 (0)