Open pstaabp opened 4 years ago
Running into the same issue while working with data frames, in some cases using Symbol
is mandatory as the column name includes numbers or things like %
or ‰
.
@pstaabp if it might help, this is my current workaround:
I defined a function to replace characters preventing column names (in my case) being interpreted as symbols:
function tidy_names(old_names)
return new_names = old_names |>
#replace spaces with underscores
n -> replace.(n, ' ' => '_') |>
#remove parenthesis
n -> replace.(n,'(' => "") |>
n -> replace.(n,')' => "") |>
#remove dashes and dots
n -> replace.(n,'-' => "") |>
n -> replace.(n, '.' => "") |>
#all lowercase
n -> lowercase.(n)
end
And then I run:
rename!(df ,names(df) .=> tidy_names(names(df)))
Before feeding the df to the pipe-magic that Query.jl allows.
If we use:
The command:
does the expected rename of the column, however if:
returns the error:
but I would expect the same result. I'm using Julia 1.4.1 and Query 0.12.2.
The reason for doing this would be to rename columns with spaces in them.