@@ -520,28 +520,15 @@ def maybe_promote(dtype: DtypeObj, fill_value=np.nan):
520520 ValueError
521521 If fill_value is a non-scalar and dtype is not object.
522522 """
523- if not is_scalar (fill_value ) and not is_object_dtype ( dtype ) :
523+ if not is_scalar (fill_value ):
524524 # with object dtype there is nothing to promote, and the user can
525525 # pass pretty much any weird fill_value they like
526- raise ValueError ("fill_value must be a scalar" )
527-
528- # if we passed an array here, determine the fill value by dtype
529- if isinstance (fill_value , np .ndarray ):
530- if issubclass (fill_value .dtype .type , (np .datetime64 , np .timedelta64 )):
531- fill_value = fill_value .dtype .type ("NaT" , "ns" )
532- else :
533-
534- # we need to change to object type as our
535- # fill_value is of object type
536- if fill_value .dtype == np .object_ :
537- dtype = np .dtype (np .object_ )
538- fill_value = np .nan
539-
540- if dtype == np .object_ or dtype .kind in ["U" , "S" ]:
541- # We treat string-like dtypes as object, and _always_ fill
542- # with np.nan
543- fill_value = np .nan
544- dtype = np .dtype (np .object_ )
526+ if not is_object_dtype (dtype ):
527+ # with object dtype there is nothing to promote, and the user can
528+ # pass pretty much any weird fill_value they like
529+ raise ValueError ("fill_value must be a scalar" )
530+ dtype = np .dtype (object )
531+ return dtype , fill_value
545532
546533 # returns tuple of (dtype, fill_value)
547534 if issubclass (dtype .type , np .datetime64 ):
0 commit comments