I am happy to announce the 0.8.0 release of DataFramesMeta.
This comes shortly after the 0.7.0 release. We are working quickly and implementing breaking changes in pursuit of a 1.0 release.
The changes are
-
@where
has been deprecated in favor of@subset
and@subset!
. This makes DataFramesMeta.jl more consistent with DataFrames.jl
julia> df = DataFrame(a = [1, 2], b = [3, 4])
2×2 DataFrame
Row │ a b
│ Int64 Int64
─────┼──────────────
1 │ 1 3
2 │ 2 4
julia> @subset df begin
:a .<= 1
:b .== 3
end
1×2 DataFrame
Row │ a b
│ Int64 Int64
─────┼──────────────
1 │ 1 3
julia> @subset! df begin
:a .<= 1
:b .== 3
end;
julia> df
1×2 DataFrame
Row │ a b
│ Int64 Int64
─────┼──────────────
1 │ 1 3
-
In transformation macros, i.e.
@select
,@select!
,@transform
,@transform!
,@by
,@combine
, the left hand side of the equation, i.e. the new variable being created, needs to be aSymbol
. You need to write:y = f(:x)
rather thany = f(:x)
.This change was made because it makes the LHS and RHS of a transformation more consistent. Visually, now any time you see
:x
, it refers to column.
julia> df = DataFrame(a = [1, 2], b = [3, 4])
2×2 DataFrame
Row │ a b
│ Int64 Int64
─────┼──────────────
1 │ 1 3
2 │ 2 4
julia> @transform df :c = :a + :b
2×3 DataFrame
Row │ a b c
│ Int64 Int64 Int64
─────┼─────────────────────
1 │ 1 3 4
2 │ 2 4 6
julia> @select df :x = 100
2×1 DataFrame
Row │ x
│ Int64
─────┼───────
1 │ 100
2 │ 100
julia> @combine df :z = first(:a)
1×1 DataFrame
Row │ z
│ Int64
─────┼───────
1 │ 1
Old syntax still works, and we will allow a deprecation period.
- Finally, and this is very niche, we have deprecated returning a Tables.jl-compatible object from
@combine
and@by
without an explicit@astable
flag. Previously, you could write
julia> @combine df (x = first(:a), y = last(:b))
This would create the syntax
combine(df, [:a, :b] => (...) => AsTable)
Now we require an explicit use of AsTable
on the LHS to do this.
julia> @combine df cols(AsTable) = (x = first(:a), y = last(:b))
1×2 DataFrame
Row │ x y
│ Int64 Int64
─────┼──────────────
1 │ 1 4
cols
has been the syntax for using column names on the LHS programmatically for a while. So it should be intuitive that cols(AsTable) = ...
creates the expression ... => AsTable
.
The next planned changes are
- Continue to make it easier to do row-wise operations, via
@rtransform
,@rselect
, etc. which will be row-wise by default. See here. - Replace
cols
as the syntax to use column names programmatically with$
, as in DataFrameMacros.jl. The PR is here.
Enjoy!