Ju_ska
1
Hi,
I have something like:
a = [["a", "1" ,"11"],
["b", "2" ,"22"],
["c", "3" ,"33"]]
3-element Vector{Vector{String}}:
["a", "1", "11"]
["b", "2", "22"]
["c", "3", "33"]
And I would like to get e.g. the “a, b, c” or “1, 2, 3” vectors.
Tried various [:,:][…] combos with success.
Are you looking for something more sophisticated than the following?
julia> map(v -> v[1], a)
3-element Vector{String}:
"a"
"b"
"c"
1 Like
Ju_ska
3
Nope, I wondered if the [:,:] kind of syntax would be usable.
Working fine, thanks.
julia> getindex.(a,1)
3-element Vector{String}:
"a"
"b"
"c"
also works
3 Likes
nilshg
5
And in the specific case for the a, b, c vector
julia> first.(a)
3-element Vector{String}:
"a"
"b"
"c"
(or last for the last “column”, but getindex more generally as mentioned above)