Skip to content

Commit 6fe3936

Browse files
committed
TST: Check Series when cast to object has float in object column (pandas-dev#35603).
1 parent f8696d5 commit 6fe3936

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

pandas/tests/series/test_constructors.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -1492,7 +1492,16 @@ def test_constructor_cast_object(self, index):
14921492
s = Series(index.astype(object), dtype=object)
14931493
exp = Series(index).astype(object)
14941494
tm.assert_series_equal(s, exp)
1495-
1495+
1496+
def test_constructor_with_float_cast_object(self):
1497+
# GH#35603
1498+
# data after casting is float not int
1499+
ser = Series([1.0]).astype(object)
1500+
val = ser.iloc[0]
1501+
assert ser.dtype == "object"
1502+
assert isinstance(val, float)
1503+
assert val == 1.0
1504+
14961505
@pytest.mark.parametrize("dtype", [np.datetime64, np.timedelta64])
14971506
def test_constructor_generic_timestamp_no_frequency(self, dtype, request):
14981507
# see gh-15524, gh-15987

0 commit comments

Comments
 (0)