Skip to content

invalid index with SubDataFrame and copycols = false #3515

@jkrumbiegel

Description

@jkrumbiegel

MWE:

julia> df = DataFrame(a = [1, 2, 3])
3×1 DataFrame
 Row │ a     
     │ Int64 
─────┼───────
   11
   22
   33

julia> v = @view df[1:2, :]
2×1 SubDataFrame
 Row │ a     
     │ Int64 
─────┼───────
   11
   22

julia> select(v, :a => ByRow(x -> x + 1) => :a)
2×1 DataFrame
 Row │ a     
     │ Int64 
─────┼───────
   12
   23

julia> select(v, :a => ByRow(x -> x + 1) => :a; copycols = false)
ERROR: ArgumentError: invalid index: :a => (ByRow{var"#618#619"}(var"#618#619"()) => :a) of type Pair{Symbol, Pair{ByRow{var"#618#619"}, Symbol}}
Stacktrace:
 [1] getindex(x::DataFrames.Index, idx::Pair{Symbol, Pair{ByRow{var"#618#619"}, Symbol}})
   @ DataFrames ~/.julia/packages/DataFrames/rwKZk/src/other/index.jl:183
 [2] manipulate(dfv::SubDataFrame{…}, args::Any; copycols::Bool, keeprows::Bool, renamecols::Bool)
   @ DataFrames ~/.julia/packages/DataFrames/rwKZk/src/abstractdataframe/selection.jl:1836
 [3] select(df::SubDataFrame{…}, args::Any; copycols::Bool, renamecols::Bool, threads::Bool)
   @ DataFrames ~/.julia/packages/DataFrames/rwKZk/src/abstractdataframe/selection.jl:1303
 [4] top-level scope
   @ REPL[25]:1
Some type information was truncated. Use `show(err)` to see complete types.

julia> select(df, :a => ByRow(x -> x + 1) => :a; copycols = false)
3×1 DataFrame
 Row │ a     
     │ Int64 
─────┼───────
   12
   23
   34

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions