为什么我不能更改变量的 dtype?



我正在做一些名为TitanicSpaceship的Kaggle比赛(https://www.kaggle.com/competitions/spaceship-titanic)和我有一个错误:

train['CryoSleep'] = train['CryoSleep'].map({'False':0, 'True':1}).astype(int)
IntCastingNaNError: Cannot convert non-finite values (NA or inf) to integer

我不知道该怎么办。

我试着看看是否有一个问题与Pandas函数称为dropna(),但它没有改变什么。

Pandas不支持INT系列中的NAN值。您可以:a)删除包含NAN值的行并将其转换为INTb)转换为FLOAT,如果适合您的情况

最新更新