@@ -1081,26 +1081,6 @@ def _infer_dtype_from_scalar(val):
10811081 return dtype , val
10821082
10831083
1084- def _maybe_cast (dtype , value ):
1085- """
1086- If `dtype` is date-like, then:
1087- if `value` == nan, then convert to NaT
1088- if `value` is an integer or integer array, convert to `dtype`
1089- """
1090- if dtype in _DATELIKE_DTYPES :
1091- if np .isscalar (value ):
1092- if isnull (value ):
1093- return tslib .iNaT
1094- elif is_integer (value ):
1095- return np .array (value , dtype = dtype )
1096-
1097- elif isinstance (value , np .ndarray ):
1098- if issubclass (dtype .type , np .integer ):
1099- return np .array (value , dtype = dtype )
1100-
1101- return value
1102-
1103-
11041084def _maybe_promote (dtype , fill_value = np .nan ):
11051085
11061086 # if we passed an array here, determine the fill value by dtype
@@ -1186,8 +1166,18 @@ def _maybe_upcast_putmask(result, mask, other):
11861166 """
11871167
11881168 if mask .any ():
1189-
1190- other = _maybe_cast (result .dtype , other )
1169+ # Two conversions for date-like dtypes that can't be done automatically
1170+ # in np.place:
1171+ # NaN -> NaT
1172+ # integer or integer array -> date-like array
1173+ if result .dtype in _DATELIKE_DTYPES :
1174+ if lib .isscalar (other ):
1175+ if isnull (other ):
1176+ other = tslib .iNaT
1177+ elif is_integer (other ):
1178+ other = np .array (other , dtype = result .dtype )
1179+ elif is_integer_dtype (other ):
1180+ other = np .array (other , dtype = result .dtype )
11911181
11921182 def changeit ():
11931183
0 commit comments