Awesome thank you so much! I really appreciate it and will let you know if I come across anything not covered.
Sorry I’m a little confused about the different rules under different versions of julia. I assume this is why you mention that “any project should be accompanied by a complete specification of environment.”
So under Julia 1.7.2, DataFrames.jl 1.3.4 “the convenience syntax for getproperty
using.
accessor does not work for symbols containing spaces and we need to do an explicit getproperty
call.”
Is it the case that under Julia v1.8 and DataFrames v1.4.4 the .
accessor now works on both Symbol
and string
for symbols containing spaces without the get property
call?
dfsymbl = DataFrame(Symbol("first") => [6,7,8,9], Symbol("first last") => [1,2,3,4])
4×2 DataFrame
Row │ first first last
│ Int64 Int64
─────┼───────────────────
1 │ 6 1
2 │ 7 2
3 │ 8 3
4 │ 9 4
dfsymbl."first last"
4-element Vector{Int64}:
1
2
3
4
dfstrng = DataFrame("first" => [6,7,8,9], "first last" => [1,2,3,4])
4×2 DataFrame
Row │ first first last
│ Int64 Int64
─────┼───────────────────
1 │ 6 1
2 │ 7 2
3 │ 8 3
4 │ 9 4
dfstrng."first last"
4-element Vector{Int64}:
1
2
3
4
I’m not sure if this is a version issue or if I was accidentally generating strings in both cases?
Also under Julia v1.7.2 and DataFrames. jl v1.3.4.
“The second important aspect is that all functions that manipulate column names in DataFrames.jl work with strings. This is natural, as symbol manipulation is not supported by Julia.”
Is it correct to assume that even with future versions of Julia, some DataFrame column name manipulations may continue to work exclusively for strings
and not work for Symbols
?
The example provided seems to work with Symbols
but I wasn’t sure whether this should be regarded as an exception or seen as a rule going forward?
julia> df = DataFrame(:col1 => 1, Symbol("col 2") => 2)
1×2 DataFrame
Row │ col1 col 2
│ Int64 Int64
─────┼──────────────
1 │ 1 2
select(df, Cols(startswith("c")) .=> identity .=> uppercase)
1×2 DataFrame
Row │ COL1 COL 2
│ Int64 Int64
─────┼──────────────
1 │ 1 2