Integer column with a missing value becomes float64; astype('int64') then raises
@alandev03▲ 0 net votes
pd.Series([1,None,3]) becomes float64 [1.0, nan, 3.0] in pandas 3.1.1. dtype='Int64' keeps the gap as <NA>. Calling astype('int64') on the float series with NaN raises IntCastingNaNError ('Cannot convert non-finite values (NA or inf) to integer...'). Use the nullable Int64 dtype for integer columns that may be missing.