dataframe - Rust polars: IntoSeries 特征没有为 &Series 实现
问题描述
我是 Rust 的新手,所以如果这个问题听起来很愚蠢,我很抱歉。我正在尝试深入polars
了解如何在 Rust 中使用数据框和系列。我现在正在尝试读取数据框,提取一列,从数据框中删除该列并将该列重新添加回数据框:
use polars::prelude::*;
use polars::frame::DataFrame;
use polars::series::IntoSeries;
fn main() {
// 1. read an input csv file and create a dataframe.
// 2. get a dataframe column
let series_column = df.column("COLUMN_NAME").unwrap();
// 3. drop this column
df.drop_in_place("COLUMN_NAME");
// 4. re-insert that column at index 0
let new_df = df.insert_at_idx(0, series_column);
虽然我尝试了很多方法,但我总是有这个错误:
error[E0277]: the trait bound `&Series: IntoSeries` is not satisfied
--> src/main.rs:78:36
|
78 | let new_df = df.insert_at_idx(0, series_column);
| ^^^^^^^^^^^^ the trait `IntoSeries` is not implemented for `&Series`
|
= help: the following implementations were found:
<Series as IntoSeries>
}
看这help
条线似乎有一个特征混淆,但我不知道如何解决这个问题。我哪里错了?谢谢
解决方案
推荐阅读
- python-3.x - 如何从多个小部件 ipywidgets 中获取观察值
- javascript - 如何按属性值的长度过滤重复项
- python - 如何在 Pandas 中将一行合并到最近的行(基于时间戳)?
- php - Codeigniter 3 显示带有子类别和产品的主类别
- excel - 小时:分钟的 Excel 格式代码,不带前导零
- excel - 从电子邮件打开 excel 时如何停止 excel 计算任何公式、计算、错误和背景刷新等
- python - Numpy 从缓冲区读取 12 位支持的字节
- python - 表单识别器 V2 / 成本呈爆炸式增长
- python - 用户输入的字典列表 Python
- javascript - 遍历这个对象数组的最佳方法是什么?