python - Dask read_csv——在`pd.read_csv`/`pd.read_table`中发现不匹配的dtypes
问题描述
我正在尝试使用 dask 读取 csv 文件,它给了我一个如下所示的错误。但问题是我想要我ARTICLE_ID
的object(string)
。任何人都可以帮助我成功读取数据吗?
追溯如下:
ValueError: Mismatched dtypes found in `pd.read_csv`/`pd.read_table`.
+------------+--------+----------+
| Column | Found | Expected |
+------------+--------+----------+
| ARTICLE_ID | object | int64 |
+------------+--------+----------+
The following columns also raised exceptions on conversion:
ARTICLE_ID:
ValueError("invalid literal for int() with base 10: ' July 2007 and 31 March 2008. Diagnostic practices of the medical practitioners for establishing the diagnosis of different types of EPTB were studied. Results: For the diagnosi\\\\'",)
Usually this is due to dask's dtype inference failing, and
*may* be fixed by specifying dtypes manually by adding:
dtype={'ARTICLE_ID': 'object'}
to the call to `read_csv`/`read_table`.
解决方案
该消息建议您将呼叫从
df = dd.read_csv('mylocation.csv', ...)
至
df = dd.read_csv('mylocation.csv', ..., dtype={'ARTICLE_ID': 'object'})
您应该将文件位置和任何其他参数更改为您之前使用的位置。如果这仍然不起作用,请更新您的问题。
推荐阅读
- reactjs - 反应 useState 钩子无法正常工作
- r - 应用函数中的条件语句在 R 中无法正常工作
- javascript - 如何获取使用 Javascript 中的表单对象检查的复选框的值
- amazon-web-services - 如何从账户 A 中的 Lambda(VPC 中的 Lambda)调用账户 B 中的 AWS Lambda 函数(VPC 中的这个 Lambda)
- express - 如何减慢我的快速服务器响应以允许 react-admin getOne() 函数工作?
- php - Laravel 政策不断允许用户
- webhooks - 如何在结帐页面显示自定义运费
- ios - (Swift)告诉我无法查询项目的原因
- java - 警告:已解决 [org.springframework.web.HttpMediaTypeNotSupportedException:不支持内容类型“应用程序/json”]
- r - 无法从 Github 安装“Velocyto.R”