Split and flatten a field from CSV and use as DataFrame

There is a flatten function in DataFrames that does what you want.

julia> people
3×3 DataFrame
│ Row │ name   │ goodat               │ goodatarray                 │
│     │ String │ String               │ Array{SubString{String},1}  │
├─────┼────────┼──────────────────────┼─────────────────────────────┤
│ 1   │ john   │ gardening            │ ["gardening"]               │
│ 2   │ marry  │ teaching,negotiation │ ["teaching", "negotiation"] │
│ 3   │ tim    │                      │ [""]                        │

julia> flatten(people, :goodatarray)
4×3 DataFrame
│ Row │ name   │ goodat               │ goodatarray │
│     │ String │ String               │ SubString…  │
├─────┼────────┼──────────────────────┼─────────────┤
│ 1   │ john   │ gardening            │ gardening   │
│ 2   │ marry  │ teaching,negotiation │ teaching    │
│ 3   │ marry  │ teaching,negotiation │ negotiation │
│ 4   │ tim    │                      │             │

After you flatten, the join should work as you expected.

1 Like