Dask支持带有标头的CSV文件(Dask support for CSV file with header)

编程入门 行业动态 更新时间:2024-10-09 05:20:37
Dask支持带有标头的CSV文件(Dask support for CSV file with header)

似乎dask不支持读取包含标头的CSV文件。 当我尝试阅读它时,我得到了

TypeError: 'NoneType' object has no attribute '__getitem__'

我可以用pandas读取相同的文件没有问题,并且没有标题的dask,但是他们将第一行的dask属性作为标题。 这是一个错误吗?

It seems that dask does not support reading a CSV file that includes a header. When I try to read it I get

TypeError: 'NoneType' object has no attribute '__getitem__'

I can read the same file with pandas with no problem and with dask without the header, but them dask attributes the first line as the header. Is this a bug?

最满意答案

Dask.dataframe支持包含标题的CSV文件:

In [1]: cat foo.csv name,amount alice,100 bob,200 In [2]: import dask.dataframe as dd In [3]: dd.read_csv('foo.csv').compute() Out[3]: name amount 0 alice 100 1 bob 200

但通常CSV文件可能很棘手。 如果您提出一个失败的示例文件的问题 ,我们可以追踪正在发生的事情并解决问题。

Dask.dataframe supports CSV files with headers:

In [1]: cat foo.csv name,amount alice,100 bob,200 In [2]: import dask.dataframe as dd In [3]: dd.read_csv('foo.csv').compute() Out[3]: name amount 0 alice 100 1 bob 200

But generally CSV files can be tricky. If you raise an issue with a sample file that fails we can track down what's going on and resolve the problem.

更多推荐

本文发布于:2023-08-04 19:24:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1419224.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件   CSV   Dask   header   file

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!