pola-rs / polars

Dataframes powered by a multithreaded, vectorized query engine, written in Rust
https://docs.pola.rs
Other
29.93k stars 1.93k forks source link

Generalize the type of the input to rename from dict to mapping #19400

Open DavideCanton opened 2 hours ago

DavideCanton commented 2 hours ago

Description

Not really sure if this should be a feature request, but it seems the closest one to what I'm proposing.

Now the rename function accepts a dict[str, str], is it feasible to generalize it to accept Mapping[str, str] instead?

In many places I tend to use mapping as it is readonly and avoids passing mutable structures around, but each time I have to invoke df.rename I have to do df.rename(dict(mapping)) that feels redundant.

alexander-beedie commented 2 hours ago

Doesn't sound unreasonable; want to make a PR? :)

DavideCanton commented 2 hours ago

Sure, I'll try when I have some time!