如何将数据框的列作为系列获取

huangapple go评论65阅读模式
英文:

How do I get a column of a dataframe as a series

问题

如何将"start"作为一个序列获取?我看不到一个名为to_series或类似的方法。

英文:

I have the following code:

use polars::prelude::*;
use polars_lazy::prelude::*;

pub fn main() -> Result<(), PolarsError> {
    let df = df! (
        "start" => &[3, 8, 5],
        "end" => &[6, 9, 7],
        "idx" => &[0, 1, 2],
    )?;
}

How do I get "start" as a series? I can't see a to_series or anything.

答案1

得分: 1

那很容易:

let s = df.column("start").unwrap();
print!("{}", s);
英文:

That was easy:

let s = df.column("start").unwrap();
print!("{}", s);

huangapple
  • 本文由 发表于 2023年5月28日 18:56:23
  • 转载请务必保留本文链接:https://go.coder-hub.com/76351122.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定