chunk_iter = pd.read_csv(source, chunksize=3000)
for chunk in chunk_iter:
floats = chunk.select_dtypes(include=['floating'], exclude=None) # select only columns that are float
notna= floats.columns[floats.notna().any()].tolist() # grab the name of all float cols without NaN
floats[notna] = floats[notna].astype(int)
print ('converted items in these {} columns to int'.format(notna))
这是我的代码,我认为它应该能够获取所有的浮动列并将它们转换为int但是我收到一个错误,表明那里的某处有一个Nan或inf值。
我想我有点困惑,因为我会认为notna变量会找到所有带有NaN的列并排除它们?