我正在尝试使用 Dask 从谷歌存储桶中读取和写入。使用一堆csv
文件有效,但不方便(速度较慢,无法压缩,无法仅读取某些列),因此我尝试使用该apache parquet
格式。
写作似乎工作正常:
import dask.dataframe as dd
pandas_df = pd.DataFrame({'x' : [2,3, 2], 'y': [1, 0, 0]})
dask_df = dd.from_pandas(pandas_df, npartitions=2)
dask_df.to_parquet("gcs://my_google_bucket/test/")
但是当我试图读回来
read_again_df = dd.read_parquet("gcs://my_google_bucket/test/")
我收到一个未实现的错误:
AttributeError Traceback (most recent call last)
~/miniconda3/envs/env1/lib/python3.6/site-packages/dask/bytes/core.py in get_pyarrow_filesystem(fs)
520 try:
--> 521 return fs._get_pyarrow_filesystem()
522 except AttributeError:
AttributeError: 'DaskGCSFileSystem' object has no attribute '_get_pyarrow_filesystem'
During handling of the above exception, another exception occurred:
NotImplementedError Traceback (most recent call last)
<ipython-input-42-ef1fc41d04d5> in <module>()
----> 1 read_again = dd.read_parquet("gcs://my_google_bucket/test/")
~/miniconda3/envs/env1/lib/python3.6/site-packages/dask/dataframe/io/parquet.py in read_parquet(path, columns, filters, categories, index, storage_options, engine, infer_divisions)
991
992 return read(fs, fs_token, paths, columns=columns, filters=filters,
--> 993 categories=categories, index=index, infer_divisions=infer_divisions)
994
995
~/miniconda3/envs/env1/lib/python3.6/site-packages/dask/dataframe/io/parquet.py in _read_pyarrow(fs, fs_token, paths, columns, filters, categories, index, infer_divisions)
505 columns = list(columns)
506
--> 507 dataset = pq.ParquetDataset(paths, filesystem=get_pyarrow_filesystem(fs))
508 if dataset.partitions is not None:
509 partitions = [n for n in dataset.partitions.partition_names
~/miniconda3/envs/env1/lib/python3.6/site-packages/dask/bytes/core.py in get_pyarrow_filesystem(fs)
522 except AttributeError:
523 raise NotImplementedError("Using pyarrow with a %r "
--> 524 "filesystem object" % type(fs).__name__)
NotImplementedError: Using pyarrow with a 'DaskGCSFileSystem' filesystem object
我猜这意味着dask
仍然无法直接从谷歌云服务读取镶木地板文件。是否有任何间接的方法可以使用,例如使用pyarrow
?
我想要保留的是延迟加载事物然后dask
用于进行数据转换的能力。
谢谢!