Open mrufsvold opened 2 weeks ago
You can rename columns with a Dict
. (Sorry this is as a photo because I'm afk right now) would something like this work for what you need? Using !!Dict
you can pass a Dict
to rename
to rename multiple columns at once
@rename_with
supports renaming with a function as well
julia> @rename_with(df, str -> str_remove_all(str, "_a"), !term_a)
Oh, great! Did I miss this in the docs or is this actually a request for this to be documented?
No this was something I tried doing after seeing it done on Twitter in tidyverse and I had a screenshot handy. Putting an example in the docstrings is a great idea tho
I'd like to rename columns with a
Dictionary
or aFunction
.@rename
only allows for static assignment (easily... I still don't fully have my head around interpolation).Would it be possible to add
@rename_with(x)
which passesx
toDataFrames.rename
, wherex
is interpolated automatically? One small quirk of doing this is that the position of theDataFrame
is different for different methods ofDataFrames.rename
:The later supports
do
syntax, but it would mean some type detection would need to happen to figure out which method to call with@rename_with
.Edit: As I wrote this, it might make sense to add
@select_with(x)
which does a similar thing (returnsdf[ : , x()]
).