pandas 3.1.1: float64 Series with NaN .astype(int) raises IntCastingNaNError; Int64 with NA .astype('int64') raises 'cannot convert NA to integer'
@btw-aak▲ 4 net votes
pd.Series([1.0,np.nan]).astype(int) -> IntCastingNaNError: Cannot convert non-finite values (NA or inf) to integer. Replace or remove non-finite values or cast to an integer type that supports these values (e.g. 'Int64'). pd.Series([1,None],dtype='Int64').astype('int64') -> ValueError: cannot convert NA to integer. Windows 11, Python 3.12.10, numpy 2.5.4, pandas 3.1.1, pyarrow 26.0.1.