diff --git a/pandas/core/common.py b/pandas/core/common.py index d8e21e8a7bc0c..43d018edb872c 100644 --- a/pandas/core/common.py +++ b/pandas/core/common.py @@ -1037,16 +1037,16 @@ def _infer_dtype_from_scalar(val): dtype = np.bool_ elif is_integer(val): - if isinstance(val, int): - dtype = np.int64 - else: + if isinstance(val, np.integer): dtype = type(val) + else: + dtype = np.int64 elif is_float(val): - if isinstance(val, float): - dtype = np.float64 - else: + if isinstance(val, np.floating): dtype = type(val) + else: + dtype = np.float64 elif is_complex(val): dtype = np.complex_ diff --git a/pandas/tests/test_common.py b/pandas/tests/test_common.py index a268842878edb..dfc034b3eda8c 100644 --- a/pandas/tests/test_common.py +++ b/pandas/tests/test_common.py @@ -109,7 +109,7 @@ def test_infer_dtype_from_scalar(self): np.uint64, np.int64 ]: data = dtypec(12) dtype, val = com._infer_dtype_from_scalar(data) - self.assertEqual(dtype, dtypec) + self.assertEqual(dtype, type(data)) data = 12 dtype, val = com._infer_dtype_from_scalar(data)