Renaming columns in DataFramesMeta with spaces

I’ve created the following dataset:

d = DataFrame(x=randn(100))
d[Symbol("Y 2")] = randn(100)

I can rename the second column via

rename!(d, Symbol("Y 2") => :Y)

But I would like to rename it via a DataFramesMeta chain.

I can do

@linq d |> select(X=:x)


@linq d |> select(Y=Symbol("Y 2"))

drops the column Y 2 and adds the column Y with only one row with the value “Y 2”


@linq d |> select(X=Symbol("x"))

Does something similar. Anyway to get around this, or do I need to use rename!?

I think this is a bug in DataFramesMeta, and you should file an issue. I think this has to do with how the syntax tree looks for Symbol("Y 2") vs. :Y2.

I’ve created an issue here for any interested.