DataFrame transform with ByRow can’t handle Date values?

By putting a vector on the right hand side you’re indicating that you are expecting a multi-column output, and DataFrames will attempt to iterate over the output to give you this. So the more obvious way to “fix” your MWE is to have a symbol (rather than a length-one vector of Symbols) on the RHS:

julia> transform(df, [:b] => ByRow(x -> x) => :c)
1×3 DataFrame
 Row │ a      b           c          
     │ Int64  Date        Date       
─────┼───────────────────────────────
   1 │     1  2022-04-18  2022-04-18

If this is right maybe there’s an argument here to special case lenght-one vectors on the RHS @bkamins?

Also no need for ByRow here afaict, you could just have (x -> x) or maybe even more obvious identity as your transformation. (I would actually just write df.c = df[:, b]).

2 Likes