问题描述 使用df['col'].astype(int)出现如题错误。 原因是col列有些记录是空,所以没法转成int。 解决方案 df['col'].fillna(0) 将此列空值填充为0或其他数字,然后再使用df['col'].astype(int)转换数据格式。 References Data type conversion error: ValueError: Cannot convert non-finite values (NA or inf) to integer [duplicate]