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 200But 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.
更多推荐
发布评论