Skip to content

Commit 48474e0

Browse files
committed
dtype fix for GH9804 on win32
1 parent 2ae575c commit 48474e0

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

pandas/core/generic.py

+11-3
Original file line numberDiff line numberDiff line change
@@ -3341,10 +3341,18 @@ def where(self, cond, other=np.nan, inplace=False, axis=None, level=None,
33413341

33423342
matches = (new_other == np.array(other))
33433343
if matches is False or not matches.all():
3344-
other = np.array(other)
3344+
3345+
# coerce other to a common dtype if we can
3346+
if com.needs_i8_conversion(self.dtype):
3347+
try:
3348+
other = np.array(other, dtype=self.dtype)
3349+
except:
3350+
other = np.array(other)
3351+
else:
3352+
other = np.asarray(other)
3353+
other = np.asarray(other, dtype=np.common_type(other, new_other))
33453354

3346-
# we can't use our existing dtype
3347-
# because of incompatibilities
3355+
# we need to use the new dtype
33483356
try_quick = False
33493357
else:
33503358
other = new_other

0 commit comments

Comments
 (0)