You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Due to the way @rename searches for column names, it is impossible to rename from/to names which have special characters in them. E.g. @rename(Symbol("#abc def.") => :newname) does not work.
Just came across this.
It's tedious to work with long (multi-word) collumn-headers that might come from reading in a csv file.
Is there any workaround?
df |>@map((; Symbol("Cool name")=>_.bat, _.bar)) # One direction
df |>@map((bat = _[Symbol("Cool name")],_.bar)) # Can be a bit simpler in the other direction
It's not pretty, and one has to explicitly list all the columns that one wants to keep.
It also feels really strange that df |> @rename(:bar => :a) works, but df |> @rename(:bar => Symbol("a")) fails with a strange error message.
ERROR: MethodError: no method matching getindex(::Nothing, ::Int64)
Stacktrace:
[1] @rename(::LineNumberNode, ::Module, ::Vararg{Any,N} where N) at /home/ilyagr/.julia/packages/Query/85Sw7/src/table_query_macros.jl:149
[2] include_string(::Function, ::Module, ::String, ::String) at ./loading.jl:1088
P.S. My use-case is not actually that I have spaces in the name, but rather that I'd like to use Symbol("best_$x") where x is a variable.
Due to the way
@renamesearches for column names, it is impossible to rename from/to names which have special characters in them. E.g.@rename(Symbol("#abc def.") => :newname)does not work.