Reputation: 1529
According to this blog by the author of DataFrames.jl the following line of code should work select(df, :name => ByRow(split) => [:firsname, :lastname])
. However, I got an error.
Do I overlook something here?
using DataFrames
using CSV
using Pkg
df = DataFrame(id = 1:6,
name = ["Aaron Aardvark", "Belen Barboza",
"春 陈", "Даниил Дубов",
"Elżbieta Elbląg", "Felipe Fittipaldi"])
select(df, :name => ByRow(split) => [:firsname, :lastname])
# expected this
6×2 DataFrame
Row │ firsname lastname
│ SubStrin… SubStrin…
─────┼───────────────────────
1 │ Aaron Aardvark
2 │ Belen Barboza
3 │ 春 陈
4 │ Даниил Дубов
5 │ Elżbieta Elbląg
6 │ Felipe Fittipaldi
# but got this
ArgumentError: Unrecognized column selector: :name => (ByRow{typeof(split)}(split) => [:firsname, :lastname])
in top-level scope at Repos/Thesis/src/scripts/stackoverflow.jl:23
in select at DataFrames/GtZ1l/src/abstractdataframe/selection.jl:493
in #select#296 at DataFrames/GtZ1l/src/abstractdataframe/selection.jl:493
in manipulate##kw at DataFrames/GtZ1l/src/abstractdataframe/selection.jl:558
in #manipulate#301 at DataFrames/GtZ1l/src/abstractdataframe/selection.jl:566
in collect at base/array.jl:686
in iterate at base/generator.jl:47
in at base/none
in normalize_selection at DataFrames/GtZ1l/src/abstractdataframe/selection.jl:42
# However this does work
select(df, :name => ByRow(split))
6x1 DataFrame
│ Row │ name_split │
│ │ Array… │
├─────┼──────────────────────────┤
│ 1 │ ["Aaron", "Aardvark"] │
│ 2 │ ["Belen", "Barboza"] │
│ 3 │ ["春", "陈"] │
│ 4 │ ["Даниил", "Дубов"] │
│ 5 │ ["Elżbieta", "Elbląg"] │
│ 6 │ ["Felipe", "Fittipaldi"] │
Pkg.status()
> [336ed68f] CSV v0.8.3
> [a93c6f00] DataFrames v0.22.5
VERSION
> v"1.5.3"
Upvotes: 3
Views: 125
Reputation: 1529
After reloading my environment it did work. The command works with [email protected]
. But I forgot to recompile the package after switching environment (I had an older version loaded due to compatibility issues with an other package).
Upvotes: 3