Skip to content

Commit b52b7fc

Browse files
committed
COMPAT: compat of scalars on all platforms, xref pandas-dev#11638
1 parent 4900677 commit b52b7fc

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

pandas/core/common.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -1037,16 +1037,16 @@ def _infer_dtype_from_scalar(val):
10371037
dtype = np.bool_
10381038

10391039
elif is_integer(val):
1040-
if isinstance(val, int):
1041-
dtype = np.int64
1042-
else:
1040+
if isinstance(val, np.integer):
10431041
dtype = type(val)
1042+
else:
1043+
dtype = np.int64
10441044

10451045
elif is_float(val):
1046-
if isinstance(val, float):
1047-
dtype = np.float64
1048-
else:
1046+
if isinstance(val, np.floating):
10491047
dtype = type(val)
1048+
else:
1049+
dtype = np.float64
10501050

10511051
elif is_complex(val):
10521052
dtype = np.complex_

pandas/tests/test_common.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def test_infer_dtype_from_scalar(self):
109109
np.uint64, np.int64 ]:
110110
data = dtypec(12)
111111
dtype, val = com._infer_dtype_from_scalar(data)
112-
self.assertEqual(dtype, dtypec)
112+
self.assertEqual(dtype, type(data))
113113

114114
data = 12
115115
dtype, val = com._infer_dtype_from_scalar(data)

0 commit comments

Comments
 (0)