python - 使用 pandas read_excel 丢失浮点数据类型的精度
问题描述
我正在使用 pandas read_excel 函数从 excel 中读取以下数据。当我读取数据时,我丢失了小数并且数字被格式化为整数。
# Read gdp data
df_gdp = pd.read_excel("~/Data/gdp_per_capita.xlsx", dtype={'Inflows': float, 'USD': float}, sheet_name="Data")
date Inflows USD
1980-12-31 0 0
1981-12-31 0 0
1982-12-31 0 0
1983-12-31 0 0
我也尝试将数据读取为float
,但它也不起作用。
解决方案
推荐阅读
- jenkins - 尝试使用 Homebrew 安装 jenkins 时出错
- azure-blob-storage - Azure Blob 存储不在本地存储
- c++ - C++ 使用 OpenMP #pragma 和 std:thread?
- python - 如何从 PANDASQL 中的特定日期前进/后退,例如 oracle date-1 和 impala DAYS_ADD(date,-1)
- docker - Docker 通过 Gradle,不起作用,DockerCompose 可以
- javascript - 如何根据另一个值在嵌套数组中查找一个值?
- schemacrawler - 删除 schemacrawler 中的“生成”标签
- vue.js - Vue 3 是否向后兼容 Vue 2?
- android - 如何从模块中的项目 build.gradle 访问额外的属性
- reactjs - Asp.net 核心页面未调用给出异常 NPM 脚本“启动”已退出