【问题标题】:How can python read "percentage" from excel file?python如何从excel文件中读取“百分比”?
【发布时间】:2020-11-02 14:15:15
【问题描述】:

我有一个 Excel 文件,其中一些列具有百分比值。我使用 pd.read_excel 来读取我的文件,但它给了我 1 而不是 100%。 python有什么办法可以读取所有百分比值?

我提到了Python: read a percentage value from excel using xlrd,但它没有给我想要的结果。

我该如何解决?谢谢。

【问题讨论】:

  • 乘以 100?
  • 如果你在记事本中打开excel,你会看到1。你在excel中看到100%只是因为excel中的格式。

标签: python pandas


【解决方案1】:

百分比由任何大于 1 的值表示。因此百分比为 50 (50/100) is 0.5。百分比值为 100% (100/100) is 1

要获得百分比,只需将值乘以 100。 例子: .5 * 100 = 501.0 * 100 = 100.

【讨论】:

    【解决方案2】:

    如您所见here,您可以通过参数converters 指定转换为pd.read_excel

    【讨论】:

      猜你喜欢
      • 2020-12-27
      • 1970-01-01
      • 1970-01-01
      • 2018-09-14
      • 2020-10-28
      • 2021-09-13
      • 2019-10-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多