【问题标题】:How to use Polars with WASM如何将 Polars 与 WASM 一起使用
【发布时间】:2022-11-09 23:19:40
【问题描述】:

rust 和 WASM 很新,我正在考虑将 Polars 与 WASM 一起使用,但在将 wasm-pack 与 web 目标一起使用时很难构建。我发现了一些使用极地惰性特性的说法,所以我的 Cargo.toml 看起来像:

货运.toml

polars = {version = "0.22.1", features = ["lazy"]}

编译 wasm 目标时出现以下错误:

`error[E0432]: unresolved import `sys::position`
|
51 | pub use sys::position;
|         ^^^^^^^^^^^^^ no `position` in `cursor::sys`

【问题讨论】:

    标签: rust webassembly


    【解决方案1】:

    对于任何想要这个的人,我认为以下工作, 早期阶段,但以下似乎正在工作。

    随着 0.25.0 版本的发布。

    如果添加以下内容:

    货物.toml:

    • polars-core = "*"
    • polars-lazy = "*"
    • getrandom = { 版本 = "*", 特征 = [“js”] }

    lib.rs:

    • 使用polars_core::prelude::*;
    • 使用 polars_lazy::prelude::*;

    然后像往常一样使用极地。

    示例 Wasm 函数

    #[wasm_bindgen]
    pub fn test(){
        //Log column B of DF to web console
    
        let df = df! {
             "column_a" => &[1, 2, 3, 4, 5],
             "column_b" => &["a", "b", "c", "d", "e"]
        }.unwrap();
    
        console::log_1(&df.column("column_b").unwrap().to_string().into())
    }
    

    【讨论】:

      猜你喜欢
      • 2019-03-17
      • 2020-04-06
      • 2023-01-04
      • 2021-06-18
      • 1970-01-01
      • 2020-02-29
      • 2021-01-02
      • 2022-08-24
      • 1970-01-01
      相关资源
      最近更新 更多