@@ -1081,26 +1081,6 @@ def _infer_dtype_from_scalar(val):
1081
1081
return dtype , val
1082
1082
1083
1083
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
-
1104
1084
def _maybe_promote (dtype , fill_value = np .nan ):
1105
1085
1106
1086
# if we passed an array here, determine the fill value by dtype
@@ -1186,8 +1166,18 @@ def _maybe_upcast_putmask(result, mask, other):
1186
1166
"""
1187
1167
1188
1168
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 )
1191
1181
1192
1182
def changeit ():
1193
1183
0 commit comments