gpt4 book ai didi

python - Dask read_csv-- 在 `pd.read_csv`/`pd.read_table` 中发现不匹配的 dtypes

转载 作者:行者123 更新时间:2023-12-04 17:30:12 39 4
gpt4 key购买 nike

我正在尝试使用 dask 读取 csv 文件,它给了我如下错误。但问题是我想要我的 ARTICLE_IDobject(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'})

您应该在哪里将文件位置和任何其他参数更改为您之前使用的内容。如果这仍然不起作用,请更新您的问题。

关于python - Dask read_csv-- 在 `pd.read_csv`/`pd.read_table` 中发现不匹配的 dtypes,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52486658/

39 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com