Skip to content

Commit

Permalink
TST: add test for df construction from dict with tuples (pandas-dev#2…
Browse files Browse the repository at this point in the history
…9497)

* add test for frame construction from dict with tuples

* parametrize full data_dict

* refactor parametrize
  • Loading branch information
ganevgv authored and proost committed Dec 19, 2019
1 parent 8e34072 commit 157ed14
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions pandas/tests/frame/test_constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -1424,6 +1424,23 @@ def test_from_dict_columns_parameter(self):
dict([("A", [1, 2]), ("B", [4, 5])]), columns=["one", "two"]
)

@pytest.mark.parametrize(
"data_dict, keys",
[
([{("a",): 1}, {("a",): 2}], [("a",)]),
([OrderedDict([(("a",), 1), (("b",), 2)])], [("a",), ("b",)]),
([{("a", "b"): 1}], [("a", "b")]),
],
)
def test_constructor_from_dict_tuples(self, data_dict, keys):
# GH 16769
df = DataFrame.from_dict(data_dict)

result = df.columns
expected = Index(keys, dtype="object", tupleize_cols=False)

tm.assert_index_equal(result, expected)

def test_constructor_Series_named(self):
a = Series([1, 2, 3], index=["a", "b", "c"], name="x")
df = DataFrame(a)
Expand Down

0 comments on commit 157ed14

Please sign in to comment.