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

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

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

问题

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

英文:

I have the following code:

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

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

答案1

得分: 1

那很容易:

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

That was easy:

  1. let s = df.column("start").unwrap();
  2. 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:

确定