Skip to content

Commit 677825b

Browse files
committed
cleanup
1 parent d635620 commit 677825b

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

pandas/core/dtypes/cast.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,7 @@ def maybe_promote(dtype, fill_value=np.nan):
352352
# We treat string-like dtypes as object, and _always_ fill
353353
# with np.nan
354354
fill_value = np.nan
355+
dtype = np.dtype(np.object_)
355356

356357
# returns tuple of (dtype, fill_value)
357358
if issubclass(dtype.type, np.datetime64):
@@ -424,8 +425,6 @@ def maybe_promote(dtype, fill_value=np.nan):
424425
# in case we have a string that looked like a number
425426
if is_extension_array_dtype(dtype):
426427
pass
427-
elif is_datetime64tz_dtype(dtype):
428-
pass
429428
elif issubclass(np.dtype(dtype).type, (bytes, str)):
430429
dtype = np.object_
431430

pandas/tests/dtypes/cast/test_promote.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -332,18 +332,17 @@ def test_maybe_promote_any_with_datetime64(
332332
dtype = np.dtype(any_numpy_dtype_reduced)
333333
boxed, box_dtype = box # read from parametrized fixture
334334

335-
if is_datetime64_dtype(dtype):
336-
if boxed and (
337-
box_dtype == object
338-
or (box_dtype is None and not is_datetime64_dtype(type(fill_value)))
339-
):
340-
pytest.xfail("falsely upcasts to object")
341-
else:
342-
if boxed and (
343-
box_dtype == "dt_dtype"
344-
or (box_dtype is None and is_datetime64_dtype(type(fill_value)))
345-
):
346-
pytest.xfail("mix of lack of upcasting, resp. wrong missing value")
335+
if boxed:
336+
if is_datetime64_dtype(dtype):
337+
if box_dtype == object:
338+
pytest.xfail("falsely upcasts to object")
339+
elif box_dtype is None and not is_datetime64_dtype(type(fill_value)):
340+
pytest.xfail("falsely upcasts to object")
341+
else:
342+
if box_dtype == "dt_dtype":
343+
pytest.xfail("mix of lack of upcasting, resp. wrong missing value")
344+
elif box_dtype is None and is_datetime64_dtype(type(fill_value)):
345+
pytest.xfail("mix of lack of upcasting, resp. wrong missing value")
347346

348347
# special case for box_dtype
349348
box_dtype = np.dtype(datetime64_dtype) if box_dtype == "dt_dtype" else box_dtype

0 commit comments

Comments
 (0)