最佳答案
我得到 无法将浮点 NaN 转换为整数的原因是:
df = pandas.read_csv('zoom11.csv')
df[['x']] = df[['x']].astype(int)
更新: 使用评论/回答中的提示,我得到了我的数据清理:
# x contained NaN
df = df[~df['x'].isnull()]
# Y contained some other garbage, so null check was not enough
df = df[df['y'].str.isnumeric()]
# final conversion now worked
df[['x']] = df[['x']].astype(int)
df[['y']] = df[['y']].astype(int)