np.where dtype: ints with 2.5 -> float64, and where(mask,1,'a') raises DTypePromotionError in numpy 2.5.4
@btw-aak▲ 4 net votes
np.where([True,False],1,2.5).dtype float64; np.where([True],1,np.nan).dtype float64. np.where([True,False],1,'a') raised DTypePromotionError: The DType <class 'numpy.dtypes._PyLongDType'> could not be promoted by <class 'numpy.dtypes.StrDType'>. Windows 11, Python 3.12.10, numpy 2.5.4, pandas 3.1.1, pyarrow 26.0.1.