-
Notifications
You must be signed in to change notification settings - Fork 360
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
Issues using the df[!, col]
syntax during broadcasts
#1959
Comments
Problem is they do do different things. It might be nice if it suggested both. But also there must be some bug with |
It doesn't seem to be exactly identical for me. Calling |
What you must be writing is something like:
which replaces column
is almost the same, but it is an in-place operation, so in some cases it will have a different effect (the most important is when you want to create a new column). The most important are the 1-2 functions up the stack. Chiefly - what function wanted to call Use one or the other depending on what your objective is. Now - to solve the problem - can you please share with me the stacktrace (you can cut off all proprietary methods and leave only the ones that are from Base or DataFrames.jl). The reason is that broadcasting API, as documented here does not require objects that are assigned to using broadcasted assignment to define |
Also note that the old syntax I will add (but still |
see #1960 |
Here's the stacktrace, if that helps: Got exception outside of a @test
MethodError: no method matching length(::DataFrames.LazyNewColDataFrame{Symbol})
Closest candidates are:
length(!Matched::Core.SimpleVector) at essentials.jl:582
length(!Matched::Base.MethodList) at reflection.jl:732
length(!Matched::Core.MethodTable) at reflection.jl:806
...
Stacktrace:
[1] _similar_for(::UnitRange{Int64}, ::Type, ::DataFrames.LazyNewColDataFrame{Symbol}, ::Base.HasLength) at ./array.jl:532
[2] _collect(::UnitRange{Int64}, ::DataFrames.LazyNewColDataFrame{Symbol}, ::Base.HasEltype, ::Base.HasLength) at ./array.jl:563
[3] collect(::DataFrames.LazyNewColDataFrame{Symbol}) at ./array.jl:557
[4] broadcastable(::DataFrames.LazyNewColDataFrame{Symbol}) at ./broadcast.jl:617
[5] broadcasted at ./broadcast.jl:1171 [inlined]
[6] ∇(::DataFrame, ::typeof(getindex), ::Type{Arg{1}}, ::Tuple{}, ::Array{Float64,1}, ::Array{Float64,1}, ::DataFrame, ::Function, ::Symbol) at /Users/ericperim/.julia/packages/Nabla/D60dX/src/sensitivities/indexing.jl:14
[7] ∇(::typeof(getindex), ::Type{Arg{1}}, ::Tuple{}, ::Array{Float64,1}, ::Array{Float64,1}, ::DataFrame, ::Function, ::Symbol) at /Users/ericperim/.julia/packages/Nabla/D60dX/src/sensitivities/indexing.jl:18
[8] propagate(::Branch{Array{Float64,1}}, ::Tape) at /Users/ericperim/.julia/packages/Nabla/D60dX/src/core.jl:135
[9] propagate(::Tape, ::Tape) at /Users/ericperim/.julia/packages/Nabla/D60dX/src/core.jl:146
[10] ∇ at /Users/ericperim/.julia/packages/Nabla/D60dX/src/core.jl:179 [inlined]
[11] ∇(::Branch{Float64}) at /Users/ericperim/.julia/packages/Nabla/D60dX/src/core.jl:180
...
[36] include at ./boot.jl:317 [inlined]
[37] include_relative(::Module, ::String) at ./loading.jl:1044
[38] include(::Module, ::String) at ./sysimg.jl:29
[39] include(::String) at ./client.jl:392
[40] top-level scope at none:0
[41] eval(::Module, ::Any) at ./boot.jl:319
[42] exec_options(::Base.JLOptions) at ./client.jl:243
[43] _start() at ./client.jl:425 |
Yes it helps 😄. We get an unintended interaction with
In order to handle this I think we will need to define:
@mbauman - could you kindly confirm that this is a right approach. CC @nalimilan |
I have added You can add:
to your code just to check if this resolves your case (it should). It would be great if you could confirm that all is OK. |
Just confirmed it here, and overloading |
Fixed with #1960 |
When updating my code to comply with v0.19, I was changing the
df[col]
calls todf[!, col]
as instructed. However, that led towhile it works fine if I use
df[:, col]
instead.I don't have a MWE for this, because it happens somewhere deep in a stack containing proprietary packages. However, it seems to me that the
!
syntax is creating some intermediate types under the hood for which not all properties are defined, and that can lead to issues when doing broadcasts over columns.I'd suggest that, at least, the deprecation warning be fixed to suggest the safe
:
syntax instead of the unsafe!
one.The text was updated successfully, but these errors were encountered: