Skip to content

Commit b72906a

Browse files
committed
TST: Adding DataFrame.to_dict(orient=records) numeric consistency test [Ref pandas-dev#22620]
1 parent 0de9955 commit b72906a

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

pandas/tests/frame/test_convert_to.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,3 +612,11 @@ def test_to_dict_wide(self):
612612
result = df.to_dict("records")[0]
613613
expected = {"A_{:d}".format(i): i for i in range(256)}
614614
assert result == expected
615+
616+
def test_to_dict_orient_dtype(self):
617+
# https://github.com/pandas-dev/pandas/issues/22620
618+
input_data = {'a': [1, 2, 3], 'b': [1.0, 2.0, 3.0], 'c': ['X', 'Y', 'Z']}
619+
df = DataFrame(input_data)
620+
result = {col: type(value) for col, value in df.to_dict('records')[0].items()}
621+
expected = {col: type(data[0]) for col, data in input_data.items()}
622+
assert result == expected

0 commit comments

Comments
 (0)