From ed022690174388394b1e99252df200fabe3d8398 Mon Sep 17 00:00:00 2001 From: "wishyut.pitawanik" Date: Tue, 18 Apr 2023 17:17:18 +0200 Subject: [PATCH 1/2] added test for ordered dict keys --- pandas/tests/series/test_constructors.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/pandas/tests/series/test_constructors.py b/pandas/tests/series/test_constructors.py index 0a8341476dc56..cc2e12690946b 100644 --- a/pandas/tests/series/test_constructors.py +++ b/pandas/tests/series/test_constructors.py @@ -2128,3 +2128,22 @@ def test_constructor(rand_series_with_duplicate_datetimeindex): def test_numpy_array(input_dict, expected): result = np.array([Series(input_dict)]) tm.assert_numpy_array_equal(result, expected) + + +def test_index_ordered_dict_keys(): + from collections import OrderedDict + + param_index = OrderedDict( + [ + ((("a", "b"), ("c", "d")), 1), + ((("a", None), ("c", "d")), 2), + ] + ) + series = Series([1, 2], index=param_index.keys()) + expected = Series( + [1, 2], + index=MultiIndex.from_tuples( + [(("a", "b"), ("c", "d")), (("a", None), ("c", "d"))] + ), + ) + tm.assert_series_equal(series, expected) From 99d6578403c10b10fcf945feef18827671b9befa Mon Sep 17 00:00:00 2001 From: Patrick Hoefler <61934744+phofl@users.noreply.github.com> Date: Wed, 19 Apr 2023 23:51:47 +0200 Subject: [PATCH 2/2] Update pandas/tests/series/test_constructors.py Co-authored-by: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> --- pandas/tests/series/test_constructors.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/series/test_constructors.py b/pandas/tests/series/test_constructors.py index cc2e12690946b..8cfd0682e1f5d 100644 --- a/pandas/tests/series/test_constructors.py +++ b/pandas/tests/series/test_constructors.py @@ -2131,7 +2131,7 @@ def test_numpy_array(input_dict, expected): def test_index_ordered_dict_keys(): - from collections import OrderedDict + # GH 22077 param_index = OrderedDict( [