Reputation: 157
I have a Dataframe tile_df
with some comma separated id's in each cell. I would like to extract these id's to get a list from.
If I apply
neighbours = split(tile_df.NEIGHBORS, ",")
I get only a 1-element array like this
["01SBD, 01TBE, 01TBF, 30SWJ, 30SXJ, 30SYJ, 30TWK, 30TWL, 30TXL, 30TYK, 30TYL, 31TBE, 31TBF, 60SYJ, 60TYK, 60TYL"]
But what I want is a list of strings and not only one string. Any ideas? Thank you
Upvotes: 2
Views: 537
Reputation: 69899
If I understand your problem correctly you can do it using broadcasting:
julia> using DataFrames
julia> df = DataFrame(a=["1,2,3", "4,5,6"])
2×1 DataFrame
│ Row │ a │
│ │ String │
├─────┼────────┤
│ 1 │ 1,2,3 │
│ 2 │ 4,5,6 │
julia> split.(df.a, ",")
2-element Array{Array{SubString{String},1},1}:
["1", "2", "3"]
["4", "5", "6"]
Upvotes: 2