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 does not have method to handle Pair? #2531

Closed
longhua8800w opened this issue Nov 10, 2020 · 2 comments
Closed

select does not have method to handle Pair? #2531

longhua8800w opened this issue Nov 10, 2020 · 2 comments

Comments

@longhua8800w
Copy link

julia version is 1.52
packages are:
using CSV
using DataFrames
using Pipe
using RData
using Statistics
my DataFrame is very simple:
df = @pipe train|>select(_, :v2 )
but when i use Pair in select, error happens such as:
select(df, :v2 => :a1)
##MethodError: no method matching getindex(::DataFrames.Index, ::Pair{Symbol,Symbol})
Closest candidates are:
getindex(::DataFrames.Index, !Matched::Symbol) at C:\Users\linghuxfeng.julia\packages\DataFrames\S3ZFo\src\other\index.jl:259
getindex(::DataFrames.Index, !Matched::AbstractArray{Symbol,1}) at C:\Users\linghuxfeng.julia\packages\DataFrames\S3ZFo\src\other\index.jl:260
getindex(::DataFrames.AbstractIndex, !Matched::Bool) at C:\Users\linghuxfeng.julia\packages\DataFrames\S3ZFo\src\other\index.jl:154
...

Stacktrace:
[1] select(::DataFrame, ::Pair{Symbol,Symbol}; copycols::Bool) at C:\Users\linghuxfeng.julia\packages\DataFrames\S3ZFo\src\dataframe\dataframe.jl:881
[2] select(::DataFrame, ::Pair{Symbol,Symbol}) at C:\Users\linghuxfeng.julia\packages\DataFrames\S3ZFo\src\dataframe\dataframe.jl:881
[3] top-level scope at In[6]:1
[4] include_string(::Function, ::Module, ::String, ::String) at .\loading.jl:1091
[5] execute_code(::String, ::String) at C:\Users\linghuxfeng.julia\packages\IJulia\a1SNk\src\execute_request.jl:27
[6] execute_request(::ZMQ.Socket, ::IJulia.Msg) at C:\Users\linghuxfeng.julia\packages\IJulia\a1SNk\src\execute_request.jl:86
[7] #invokelatest#1 at .\essentials.jl:710 [inlined]
[8] invokelatest at .\essentials.jl:709 [inlined]
[9] eventloop(::ZMQ.Socket) at C:\Users\linghuxfeng.julia\packages\IJulia\a1SNk\src\eventloop.jl:8
[10] (::IJulia.var"#15#18")() at .\task.jl:356

select(df, :v2 => (x -> x .- minimum(x)) => :vv2 )

MethodError: no method matching getindex(::DataFrames.Index, ::Pair{Symbol,Pair{var"#45#46",Symbol}})

Closest candidates are:
getindex(::DataFrames.Index, !Matched::Symbol) at C:\Users\linghuxfeng.julia\packages\DataFrames\S3ZFo\src\other\index.jl:259
getindex(::DataFrames.Index, !Matched::AbstractArray{Symbol,1}) at C:\Users\linghuxfeng.julia\packages\DataFrames\S3ZFo\src\other\index.jl:260
getindex(::DataFrames.AbstractIndex, !Matched::Bool) at C:\Users\linghuxfeng.julia\packages\DataFrames\S3ZFo\src\other\index.jl:154
...

Stacktrace:
[1] select(::DataFrame, ::Pair{Symbol,Pair{var"#1#2",Symbol}}; copycols::Bool) at C:\Users\linghuxfeng.julia\packages\DataFrames\S3ZFo\src\dataframe\dataframe.jl:881
[2] select(::DataFrame, ::Pair{Symbol,Pair{var"#1#2",Symbol}}) at C:\Users\linghuxfeng.julia\packages\DataFrames\S3ZFo\src\dataframe\dataframe.jl:881
[3] top-level scope at In[7]:1
[4] include_string(::Function, ::Module, ::String, ::String) at .\loading.jl:1091
[5] execute_code(::String, ::String) at C:\Users\linghuxfeng.julia\packages\IJulia\a1SNk\src\execute_request.jl:27
[6] execute_request(::ZMQ.Socket, ::IJulia.Msg) at C:\Users\linghuxfeng.julia\packages\IJulia\a1SNk\src\execute_request.jl:86
[7] #invokelatest#1 at .\essentials.jl:710 [inlined]
[8] invokelatest at .\essentials.jl:709 [inlined]
[9] eventloop(::ZMQ.Socket) at C:\Users\linghuxfeng.julia\packages\IJulia\a1SNk\src\eventloop.jl:8
[10] (::IJulia.var"#15#18")() at .\task.jl:356

it seems that DataFrames select does not have method to handle Pair.

@bkamins
Copy link
Member

bkamins commented Nov 10, 2020

You are using DataFrames.jl version 0.20.2. Please update the package to the latest version (at this moment 0.21.8, soon it will be 0.22). This will fix the problem.

@bkamins bkamins closed this as completed Nov 10, 2020
@longhua8800w
Copy link
Author

I update DataFrames to 0.21.8, problem fixed

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