English 中文(简体)
Rustpolars改装数据基
原标题:Rust Polars convert DataFrame into tuples

我使用该法典将国防军改为les子:

    // Combine vectors into a new vector of tuples
    let combined_data: Vec<(i64, i32, f64, f64)> =
        timestamp
            .into_iter()
            .zip(side.into_iter())
            .zip(size.into_iter())
            .zip(price.into_iter())
            .map(|(((ts, s), sz), pr)| (ts, s, sz, pr))
            .collect();

我也为12栏提供了版本。 没有人能够提出一种办法,以笼统的方式转换任何栏目?

问题回答

http://docs.rs/itertools/latest/itertools/macro.izip.html” rel=“nofollow noreferer”izip!

izip!(timestamp, side, size, price).collect::<Vec<_>>() // Vec of 4-tuples

即便在您的榜样中,你也只需要into_iter(),timest;zip。 这种方法仅要求其论点为IntoIterator,而不是Iterator





相关问题
Reading file with polars and ignoring errors

I would like to read in a CSV file in polars using rust, and I would like to ignore all rows that cause an error. My understanding was that using with_ignore_errors(true) would skip the rows that ...

热门标签