We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lag
groupby
transform
See the example below:
julia> using ShiftedArrays julia> df = DataFrame(x=rand(10), y=rand(1:3, 10)) 10×2 DataFrame │ Row │ x │ y │ │ │ Float64 │ Int64 │ ├─────┼──────────┼───────┤ │ 1 │ 0.606215 │ 3 │ │ 2 │ 0.128396 │ 1 │ │ 3 │ 0.194318 │ 3 │ │ 4 │ 0.139702 │ 1 │ │ 5 │ 0.766211 │ 3 │ │ 6 │ 0.806462 │ 2 │ │ 7 │ 0.162772 │ 3 │ │ 8 │ 0.863007 │ 1 │ │ 9 │ 0.269158 │ 3 │ │ 10 │ 0.105715 │ 3 │ julia> @linq df |> groupby(:y) |> transform(prevx=lag(:x)) ERROR: AssertionError: newtype_first === nothing Stacktrace: [1] _transform!(::Array{Missing,1}, ::ShiftedArray{Float64,Missing,1,SubArray{Float64,1,Array{Float64,1},Tuple{Array{Int64,1}},false}}, ::Int64, ::GroupedDataFrame{DataFrame}, ::var"#251#252", ::Array{Int64,1}, ::Array{Int64,1}) at /home/me/.julia/packages/DataFramesMeta/c88dH/src/DataFramesMeta.jl:427 [2] transform(::GroupedDataFrame{DataFrame}; kwargs::Base.Iterators.Pairs{Symbol,var"#251#252",Tuple{Symbol},NamedTuple{(:prevx,),Tuple{var"#251#252"}} }) at /home/me/.julia/packages/DataFramesMeta/c88dH/src/DataFramesMeta.jl:0 [3] top-level scope at /home/me/.julia/packages/DataFramesMeta/c88dH/src/DataFramesMeta.jl:473
However, lag works with both by and transform when called separately:
by
julia> @linq df |> by(:y, prevx=lag(:x)) 10×2 DataFrame │ Row │ y │ prevx │ │ │ Int64 │ Float64⍰ │ ├─────┼───────┼──────────┤ │ 1 │ 3 │ missing │ │ 2 │ 3 │ 0.606215 │ │ 3 │ 3 │ 0.194318 │ │ 4 │ 3 │ 0.766211 │ │ 5 │ 3 │ 0.162772 │ │ 6 │ 3 │ 0.269158 │ │ 7 │ 1 │ missing │ │ 8 │ 1 │ 0.128396 │ │ 9 │ 1 │ 0.139702 │ │ 10 │ 2 │ missing │ julia> @linq df |> transform(prevx=lag(:x)) 10×3 DataFrame │ Row │ x │ y │ prevx │ │ │ Float64 │ Int64 │ Float64⍰ │ ├─────┼──────────┼───────┼──────────┤ │ 1 │ 0.606215 │ 3 │ missing │ │ 2 │ 0.128396 │ 1 │ 0.606215 │ │ 3 │ 0.194318 │ 3 │ 0.128396 │ │ 4 │ 0.139702 │ 1 │ 0.194318 │ │ 5 │ 0.766211 │ 3 │ 0.139702 │ │ 6 │ 0.806462 │ 2 │ 0.766211 │ │ 7 │ 0.162772 │ 3 │ 0.806462 │ │ 8 │ 0.863007 │ 1 │ 0.162772 │ │ 9 │ 0.269158 │ 3 │ 0.863007 │ │ 10 │ 0.105715 │ 3 │ 0.269158 │
The text was updated successfully, but these errors were encountered:
It seems that this line https://github.com/JuliaData/DataFramesMeta.jl/blob/master/src/DataFramesMeta.jl#L390 leads to this bug.
Sorry, something went wrong.
Fixed by #163
closing - right?
No branches or pull requests
See the example below:
However,
lag
works with bothby
andtransform
when called separately:The text was updated successfully, but these errors were encountered: