i wanted to create a loop on a column in my IJulia and I came up with this error. Please what can I do to retify it.
Here is my code:
for v=1:length(col1)
col1[v] = Dates.DateTime(col1[v], “d-u-y”)
end
And I got this error:
setindex! not defined for WeakRefStrings.StringArray{String,1}
Stacktrace:
[1] error(::String, ::Type{T} where T) at .\error.jl:42
[2] error_if_canonical_setindex(::IndexLinear, ::WeakRefStrings.StringArray{String,1}, ::Int64) at .\abstractarray.jl:1081
[3] setindex!(::WeakRefStrings.StringArray{String,1}, ::DateTime, ::Int64) at .\abstractarray.jl:1072
[4] top-level scope at .\In[130]:2
I decided to try changing the code a little bit using:
i in col1
global col1[i] = Dates.DateTime(string.(col1[i]), “d-u-y”)
end
Then I still got this error;:
ArgumentError: invalid index: “4-Jul-2014” of type String
Stacktrace:
[1] to_index(::String) at .\indices.jl:297
[2] to_index(::WeakRefStrings.StringArray{String,1}, ::String) at .\indices.jl:274
[3] to_indices at .\indices.jl:325 [inlined]
[4] to_indices at .\indices.jl:322 [inlined]
[5] getindex(::WeakRefStrings.StringArray{String,1}, ::String) at .\abstractarray.jl:980
[6] top-level scope at .\In[136]:2