【问题标题】:Converting the dtype of columns in pandas without column names在没有列名的情况下转换 pandas 中列的 dtype
【发布时间】:2017-11-17 03:20:13
【问题描述】:

我正在处理从巨大的 CSV 导入的数据。 Pandas 将某些列更改为浮点数,因此现在这些列中的数字显示为浮点数!但是,我需要它们是整数。我找到了一些解决方案,但都使用列名来更改数据类型。

有没有办法改变数据类型,例如前一千列,而不用它们的名称单独寻址?

【问题讨论】:

    标签: python pandas numpy slice


    【解决方案1】:
    df.iloc[:, :1000] = df.iloc[:, :1000].astype(int)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-02-08
      • 2021-02-16
      • 2019-03-01
      • 1970-01-01
      • 2020-09-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多