Skip to content
New issue

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

@select! errors where select! does not with multi-column selection #404

Open
nathanrboyer opened this issue Nov 11, 2024 · 1 comment
Open

Comments

@nathanrboyer
Copy link

I get an unexpected error with @select! below, and the error message reads to me like it should be working.

julia> using DataFramesMeta

julia> df = DataFrame(x=1:3, y=4:6, z=7:9)
3×3 DataFrame
 Row │ x      y      z
     │ Int64  Int64  Int64
─────┼─────────────────────
   1 │     1      4      7
   2 │     2      5      8
   3 │     3      6      9

julia> @select!(df, Not(:x), :x)
ERROR: LoadError: ArgumentError: Multi-column references outside of @select, @rselect, @select! and @rselect! must be wrapped in AsTable
Stacktrace:
 [1] get_column_expr(e::Expr; allow_multicol::Bool)
   @ DataFramesMeta C:\Users\nboyer.AIP\.julia\packages\DataFramesMeta\Ga6VV\src\parsing.jl:37
 [2] get_column_expr
   @ C:\Users\nboyer.AIP\.julia\packages\DataFramesMeta\Ga6VV\src\parsing.jl:22 [inlined]
 [3] fun_to_vec(ex::Expr; gensym_names::Bool, outer_flags::@NamedTuple{…}, no_dest::Bool, allow_multicol::Bool)
   @ DataFramesMeta C:\Users\nboyer.AIP\.julia\packages\DataFramesMeta\Ga6VV\src\parsing.jl:359
 [4] fun_to_vec
   @ C:\Users\nboyer.AIP\.julia\packages\DataFramesMeta\Ga6VV\src\parsing.jl:326 [inlined]
 [5] (::DataFramesMeta.var"#56#57"{@NamedTuple{…}})(ex::Expr)
   @ DataFramesMeta .\none:0
 [6] iterate(::Base.Generator{Vector{Any}, DataFramesMeta.var"#56#57"{@NamedTuple{…}}})
   @ Base .\generator.jl:48
 [7] select!_helper(::Symbol, ::Expr, ::Vararg{Any})
   @ DataFramesMeta C:\Users\nboyer.AIP\.julia\packages\DataFramesMeta\Ga6VV\src\macros.jl:1987
 [8] var"@select!"(__source__::LineNumberNode, __module__::Module, x::Any, args::Vararg{Any})
   @ DataFramesMeta C:\Users\nboyer.AIP\.julia\packages\DataFramesMeta\Ga6VV\src\macros.jl:2116
in expression starting at REPL[8]:1
Some type information was truncated. Use `show(err)` to see complete types.

julia> select!(df, Not(:x), :x)
3×3 DataFrame
 Row │ y      z      x
     │ Int64  Int64  Int64
─────┼─────────────────────
   1 │     4      7      1
   2 │     5      8      2
   3 │     6      9      3
@pdeffebach
Copy link
Collaborator

Thank you for the bug report! Fix is in #405

pdeffebach added a commit that referenced this issue Nov 14, 2024
* add allow multicol

* add tests

* add fix

* Update src/macros.jl

Co-authored-by: Bogumił Kamiński <[email protected]>

---------

Co-authored-by: Bogumił Kamiński <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants