Skip to content

Commit

Permalink
TST: Adding to_dict numeric consistency test (pandas-dev#22620) (pand…
Browse files Browse the repository at this point in the history
  • Loading branch information
sofiane87 authored and proost committed Dec 19, 2019
1 parent 1c5eacd commit d5d1b7c
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions pandas/tests/frame/test_convert_to.py
Original file line number Diff line number Diff line change
Expand Up @@ -612,3 +612,19 @@ def test_to_dict_wide(self):
result = df.to_dict("records")[0]
expected = {"A_{:d}".format(i): i for i in range(256)}
assert result == expected

def test_to_dict_orient_dtype(self):
# https://github.com/pandas-dev/pandas/issues/22620
# Input Data
input_data = {"a": [1, 2, 3], "b": [1.0, 2.0, 3.0], "c": ["X", "Y", "Z"]}
df = DataFrame(input_data)
# Expected Dtypes
expected = {"a": int, "b": float, "c": str}
# Extracting dtypes out of to_dict operation
for df_dict in df.to_dict("records"):
result = {
"a": type(df_dict["a"]),
"b": type(df_dict["b"]),
"c": type(df_dict["c"]),
}
assert result == expected

0 comments on commit d5d1b7c

Please sign in to comment.