Skip to content

Commit 7059b7b

Browse files
sortofamudkipphoflmroeschke
authored
TST: Test for index of dict keys as tuples (#52758)
* added test for ordered dict keys * Update pandas/tests/series/test_constructors.py Co-authored-by: Matthew Roeschke <[email protected]> --------- Co-authored-by: Patrick Hoefler <[email protected]> Co-authored-by: Matthew Roeschke <[email protected]>
1 parent 2750ee2 commit 7059b7b

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

pandas/tests/series/test_constructors.py

+19
Original file line numberDiff line numberDiff line change
@@ -2128,3 +2128,22 @@ def test_constructor(rand_series_with_duplicate_datetimeindex):
21282128
def test_numpy_array(input_dict, expected):
21292129
result = np.array([Series(input_dict)])
21302130
tm.assert_numpy_array_equal(result, expected)
2131+
2132+
2133+
def test_index_ordered_dict_keys():
2134+
# GH 22077
2135+
2136+
param_index = OrderedDict(
2137+
[
2138+
((("a", "b"), ("c", "d")), 1),
2139+
((("a", None), ("c", "d")), 2),
2140+
]
2141+
)
2142+
series = Series([1, 2], index=param_index.keys())
2143+
expected = Series(
2144+
[1, 2],
2145+
index=MultiIndex.from_tuples(
2146+
[(("a", "b"), ("c", "d")), (("a", None), ("c", "d"))]
2147+
),
2148+
)
2149+
tm.assert_series_equal(series, expected)

0 commit comments

Comments
 (0)