How do I rename columns X1 and X2 using the list (excluding Time column). I can do it manually, however, this is not an efficient option to rename hundreds of columns. So, essentially, Iβm what Iβm looking for is a way to map the list of names to the columns. Any efficient solution is highly appreciated.
One possible method is to use the high-level transforms of TableTransforms.jl. For example, you can Select the columns of interest with a regular expression, and then Rename them:
The transforms are implemented in terms of the Tables.jl API, we didnβt benchmark them against a DataFrames.jl-specific solution yet. Others can help with alternative solutions with different packages.
This method could come in handy if you need to use a regular expression. For example, if you want to change the names from X1,X2,X3β¦ to Y1,Y2,Y3β¦ you can do:
Yes, thatβs an alternative too. I just find splitting the two operations more readable, since the first line indicates the names you change and the second line that you use those names to rename the dataset (just a matter of preference).
Notice that if you want to use your option, you need to actually write: rename!(s -> replace(s, r"X" => "Y"), df)