Dask + Mongo集成
项目描述
Dask-Mongo
使用Dask读写MongoDB数据
安装
dask-mongo
可以用pip
安装
pip install dask-mongo
或者用conda
conda install -c conda-forge dask-mongo
示例
import dask.bag as db
import dask_mongo
# Create Dask Bag
records = [
{"name": "Alice", "fruit": "apricots"},
{"name": "Bob", "fruit": ["apricots", "cherries"]},
{"name": "John", "age": 17, "sports": "cycling"},
]
b = db.from_sequence(records)
# Write to a Mongo database
dask_mongo.to_mongo(
b,
database="your_database",
collection="your_collection",
connection_kwargs={"host": "localhost", "port": 27017},
)
# Read Dask Bag from Mongo database
b = dask_mongo.read_mongo(
database="your_database",
collection="your_collection",
connection_kwargs={"host": "localhost", "port": 27017},
chunksize=2,
)
# Perform normal operations with Dask
names = b.pluck("name").compute()
assert names == ["Alice", "Bob", "John"]
许可证
项目详情
关闭
dask-mongo-2022.5.0.tar.gz的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | a50dc71afa5d809e7501f135d1a5b7976f16625d0bbf5f416136ae8c46eef575 |
|
MD5 | 01622cc60b96f4c467cf8fc5ea5b05b6 |
|
BLAKE2b-256 | e13b511797f289e5778587b34389f928f6f93e024edacd353555380bd76c2581 |
关闭
dask_mongo-2022.5.0-py3-none-any.whl的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 7ea5a9525e15592e9fa87980661fbe1bcffc9c49c899bdffc9f7cbf1ea8fbee0 |
|
MD5 | 926803b0aac2d2369853c0f5c58651ab |
|
BLAKE2b-256 | 569978481ee23c89bf9c18beb4dbfc675b238f16cf7eb3f064fc258b97006556 |