I am working with data imported from a huge CSV. Pandas changed some columns to float, so now the numbers in these columns get displayed as floating points! However, I need them to be integers. I found some solutions, but all used the column names to change the dtypes.
我正在处理从巨大的CSV导入的数据。 Pandas将一些列更改为float,所以现在这些列中的数字显示为浮点数!但是,我需要它们是整数。我找到了一些解决方案,但都使用列名来更改dtypes。
Is there a way to change the data type for example for the first one thousand columns without addressing them separately by their names?
有没有办法改变数据类型,例如前一千列而不用它们的名称单独解决它们?
1 个解决方案
#1
1
df.iloc[:, :1000] = df.iloc[:, :1000].astype(int)
#1
1
df.iloc[:, :1000] = df.iloc[:, :1000].astype(int)