#polars #dataframe #arrow #query-engine

polars-mongo

用于从 mongodb 集合读取 polars 数据帧的连接器

2 个不稳定版本

0.2.0 2022年9月19日
0.1.0 2022年8月21日

#37#query-engine

MIT 许可证

24KB
505

polars-mongo

此包扩展了 polars,通过 LazyFrame API 从 mongodb 集合中读取。


lib.rs:

Polars mongo 是一个连接器,可以将从 mongodb 集合读取的数据转换为 Polars 数据帧。用法

use polars::prelude::*;
use polars_mongo::prelude::*;

pub fn main() -> PolarsResult<()> {
    let connection_str = std::env::var("POLARS_MONGO_CONNECTION_URI").unwrap();
    let db = std::env::var("POLARS_MONGO_DB").unwrap();
    let collection = std::env::var("POLARS_MONGO_COLLECTION").unwrap();

    let df = LazyFrame::scan_mongo_collection(MongoScanOptions {
        batch_size: None,
        connection_str,
        db,
        collection,
        infer_schema_length: Some(1000),
        n_rows: None,
    })?
    .collect()?;

    dbg!(df);
    Ok(())
}

依赖项

~56MB
~1M SLoC