Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TST: add test for nested OrderedDict in constructor #50060

Merged
merged 5 commits into from
Dec 6, 2022
Merged
Changes from 1 commit
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
9 changes: 9 additions & 0 deletions pandas/tests/frame/test_constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -1395,6 +1395,15 @@ def test_constructor_list_of_dicts(self):
expected = DataFrame(index=[0])
tm.assert_frame_equal(result, expected)

def test_constructor_ordered_dict_nested_preserve_order(self):
nested1 = OrderedDict([("b", 1), ("a", 2)])
nested2 = OrderedDict([("b", 2), ("a", 5)])
data = OrderedDict([("col2", nested1), ("col1", nested2)])
result = DataFrame(data)
data = {"col2": [1, 2], "col1": [2, 5]}
expected = DataFrame(data=data, index=["b", "a"])
tm.assert_frame_equal(result, expected)

@pytest.mark.parametrize("dict_type", [dict, OrderedDict])
def test_constructor_ordered_dict_preserve_order(self, dict_type):
# see gh-13304
Expand Down