[ANN] DataFramesMeta 0.10.0 release

We are pleased to announce the release of DataFramesMeta.jl version 0.10.0.

This release adds the @astable macro-flag, which is similar to the @t macro-flag in DataFrameMacros.jl. Thanks to @jules for taking initiating the work on this feature.

When the @astable macro-flag is used, new columns can be created at any point in a the block of transformations, interspersed with non-transformation expressions, and you can create multiple columns which depend on one another. The syntax :y = ..., which errors outside of DataFramesMeta.jl with @astable, is used to create new columns.

julia> using DataFramesMeta

julia> df = DataFrame(a = [1, 2], b = [3, 4])
2×2 DataFrame
 Row │ a      b     
     │ Int64  Int64 
─────┼──────────────
   1 │     1      3
   2 │     2      4

julia> @rtransform df @astable begin 
           :c_1 = :a
           z = 1 + :a # no new column created
           :c_2 = :c_1 * 100
           :c_3 = :b + 10
       end
2×5 DataFrame
 Row │ a      b      c_1    c_2    c_3   
     │ Int64  Int64  Int64  Int64  Int64 
─────┼───────────────────────────────────
   1 │     1      3      1    100     13
   2 │     2      4      2    200     14

As in the rest of DataFramesMeta.jl, escaping with $ can be used to create variables programatically

julia> x_str = "x";

julia> @rtransform df @astable begin 
           $x_str = :a + :b
           :z = $x_str * 100
       end
2×4 DataFrame
 Row │ a      b      x      z     
     │ Int64  Int64  Int64  Int64 
─────┼────────────────────────────
   1 │     1      3      4    400
   2 │     2      4      6    600

This is a breaking release, which is unfortunate because there have been many breaking releases recently in DataFramesMeta.jl. In implementing this feature, We had to finally disallow an already-deprecated feature. @combine df (x1 = first(:a), x2 = first(:b)) used to create new columns :x1 and :x2. This syntax is now disallowed with two possible alternatives

For preserving the named-tuple outcome, which is best when the named tuple is a result of a function and not typed out literally.

julia> function foo(a, b)
           (x1 = first(a), x2 = first(b))
       end;

julia> @combine df $AsTable = foo(:a, :b)
1×2 DataFrame
 Row │ x1     x2    
     │ Int64  Int64 
─────┼──────────────
   1 │     1      3

using the new @astable macro when you are working with the expression literally


julia> @combine df @astable begin
           :x1 = first(:a)
           :x2 = first(:b)
       end
1×2 DataFrame
 Row │ x1     x2    
     │ Int64  Int64 
─────┼──────────────
   1 │     1      3
6 Likes