Skip to content

Commit 7cacf2e

Browse files
committed
added test cases
1 parent a22f9b9 commit 7cacf2e

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

pandas/tests/series/test_constructors.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1447,6 +1447,12 @@ def test_constructor_dict_of_tuples(self):
14471447
expected = Series([3, 6], index=MultiIndex.from_tuples([(1, 2), (None, 5)]))
14481448
tm.assert_series_equal(result, expected)
14491449

1450+
# GH 60695
1451+
data = {(1,): 3, (4, 5): 6}
1452+
result = Series(data).sort_values()
1453+
expected = Series([3, 6], index=MultiIndex.from_tuples([(1, None), (4, 5)]))
1454+
tm.assert_series_equal(result, expected)
1455+
14501456
# https://github.com/pandas-dev/pandas/issues/22698
14511457
@pytest.mark.filterwarnings("ignore:elementwise comparison:FutureWarning")
14521458
def test_fromDict(self, using_infer_string):
@@ -1878,6 +1884,15 @@ def test_constructor_dict_multiindex(self):
18781884
result = result.reindex(index=expected.index)
18791885
tm.assert_series_equal(result, expected)
18801886

1887+
# GH 60695
1888+
d = {("a",): 0.0, ("a", "b"): 1.0}
1889+
_d = sorted(d.items())
1890+
result = Series(d)
1891+
expected = Series(
1892+
[x[1] for x in _d], index=MultiIndex.from_tuples([x[0] for x in _d])
1893+
)
1894+
tm.assert_series_equal(result, expected)
1895+
18811896
def test_constructor_dict_multiindex_reindex_flat(self):
18821897
# construction involves reindexing with a MultiIndex corner case
18831898
data = {("i", "i"): 0, ("i", "j"): 1, ("j", "i"): 2, "j": np.nan}

0 commit comments

Comments
 (0)