Skip to content

Commit 29e56df

Browse files
jbrockmendeljreback
authored andcommitted
TST: Fix not-boxed maybe_promote test (#28852)
1 parent 25b1859 commit 29e56df

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

pandas/core/dtypes/cast.py

+2
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,8 @@ def maybe_promote(dtype, fill_value=np.nan):
359359
if isinstance(fill_value, datetime) and fill_value.tzinfo is not None:
360360
# Trying to insert tzaware into tznaive, have to cast to object
361361
dtype = np.dtype(np.object_)
362+
elif is_integer(fill_value) or (is_float(fill_value) and not isna(fill_value)):
363+
dtype = np.dtype(np.object_)
362364
else:
363365
try:
364366
fill_value = tslibs.Timestamp(fill_value).to_datetime64()

pandas/tests/dtypes/cast/test_promote.py

-2
Original file line numberDiff line numberDiff line change
@@ -592,8 +592,6 @@ def test_maybe_promote_datetime64_with_any(
592592
else:
593593
if boxed and box_dtype is None:
594594
pytest.xfail("does not upcast to object")
595-
if not boxed:
596-
pytest.xfail("does not upcast to object or raises")
597595

598596
# create array of given dtype; casts "1" to correct dtype
599597
fill_value = np.array([1], dtype=fill_dtype)[0]

0 commit comments

Comments
 (0)