I have some data with many rows, that I want to reorder, and in some cases rename. Because of the number of columns I wouldn't want to select and rename every single on of them. But when I use the : operator to select the remaining columns I got a result that I did not expect. The columns that I renamed are included twice:
julia> data = [2 1 3 50
52 51 53 100]
julia> names = ["col 2","col 1", "col_3", "col_50"]
julia> df = DataFrame(data, names)
2×4 DataFrame
Row │ col 2 col 1 col_3 col_50
│ Int64 Int64 Int64 Int64
─────┼─────────────────────────────
1 │ 2 1 3 50
2 │ 52 51 53 100
julia> select(df, "col 1" => :col_1, "col 2" => :col_2, :)
2×6 DataFrame
Row │ col_1 col_2 col 1 col 2 col_3 col_50
│ Int64 Int64 Int64 Int64 Int64 Int64
─────┼───────────────────────────────────────────
1 │ 1 2 1 2 3 50
2 │ 51 52 51 52 53 100
I was hoping for/expecting this
julia> select(df, "col 1" => :col_1, "col 2" => :col_2, :)
2×6 DataFrame
Row │ col_1 col_2 col_3 col_50
│ Int64 Int64 Int64 Int64
─────┼────────────────────────────
1 │ 1 2 3 50
2 │ 51 52 53 100
What do I misunderstand about the : operator.
Is there a/another way to achieve the transformation I want?