Resolving "AttributeError: module 'dask.bag' has no attribute 'from_filenames'"

Resolving "AttributeError: module 'dask.bag' has no attribute 'from_filenames'"

我正在按照一个简单的教程将 pushshift.io 中的 Reddit 评论数据加载到 dask 包中。我收到奇怪的错误:"Resolving "AttributeError:模块 'dask.bag' 没有属性 'from_filenames'”,尽管这是此处描述的标准程序:http://dask.pydata.org/en/doc-test-build/bag.html

import dask
import dask.bag as db

data = db.from_filenames("reddit_1_28_2018.txt", chunkbytes=100000).map(json.loads)

AttributeError                            Traceback (most recent call last)
<ipython-input-17-bcbd31affbfb> in <module>()
      2 import dask.bag as db
      3 
----> 4 data = db.from_filenames("reddit_1_28_2018.txt", chunkbytes=100000).map(json.loads)

AttributeError: module 'dask.bag' has no attribute 'from_filenames'

我怀疑您正在查看的资源很旧。我建议阅读 the Dask documentation 以获取最新信息。

我怀疑你在找db.read_text