From 4d05d13783468e67aba6833116d79281eb5e3241 Mon Sep 17 00:00:00 2001 From: Patrick Hoefler Date: Thu, 19 Jan 2023 22:46:41 +0100 Subject: [PATCH] TST: Add test for to_dict converting masked to python types --- pandas/tests/frame/methods/test_to_dict.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pandas/tests/frame/methods/test_to_dict.py b/pandas/tests/frame/methods/test_to_dict.py index d08323ec01ae8..e14dc8da68136 100644 --- a/pandas/tests/frame/methods/test_to_dict.py +++ b/pandas/tests/frame/methods/test_to_dict.py @@ -485,3 +485,13 @@ def test_to_dict_na_to_none(self, orient, expected): df = DataFrame({"a": [1, NA]}, dtype="Int64") result = df.to_dict(orient=orient) assert result == expected + + def test_to_dict_masked_native_python(self): + # GH#34665 + df = DataFrame({"a": Series([1, 2], dtype="Int64"), "B": 1}) + result = df.to_dict(orient="records") + assert type(result[0]["a"]) is int + + df = DataFrame({"a": Series([1, NA], dtype="Int64"), "B": 1}) + result = df.to_dict(orient="records") + assert type(result[0]["a"]) is int