79463703

Date: 2025-02-24 13:39:44
Score: 2
Natty:
Report link

The following works (thanks to a hint from @cafce25):

#![allow(unused_variables)]
use polars::prelude::*;

fn main() {
    println!("Hello, world!");
    let mut df = df! [
        "names" => ["a", "b", "c"],
        "values" => [1, 2, 3],
    ].unwrap();

    println!("{:?}", df);

    let old_name = df.get_column_names_str()[0].to_owned();
    let new_name = <PlSmallStr>::from_str("letters");
    let _ = df.rename(&old_name, new_name);
    println!("{:?}", df);
}
Reasons:
  • Blacklisted phrase (0.5): thanks
  • Has code block (-0.5):
  • User mentioned (1): @cafce25
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: Roger V.