运行代码时,我的代码setindex!没有为WeakRefStrings.StringArray {String,1}
定义CSV文件here。
using CSV EVDdata =CSV.read(raw"wikipediaEVDdatesconverted.csv") EVDdata[end-9:end,:]
错误代码为here
上的Julia 1.4.1rows, cols = size(EVDdata) for j =1:cols for i = 1:rows if !isdigit(string(EVDdata[i, j])[1]) EVDdata[i,j] = 0 end end end
我正在使用Jupter Notebook
当我运行代码时,我的代码setindex发生一个错误!未在此处为WeakRefStrings.StringArray {String,1} CSV文件定义。使用CSV EVDdata = CSV.read(raw“ wikipediaEVDdatesconverted.csv”)...
setindex!(collection, item, inds...)
是将colection[inds...] = item
降低到的功能。该错误来自CSV.read
进行不可变收集的事实。
[正如奥斯卡(Oscar)在回答中所说,setindex!
试图改变其论点,即在适当位置更改列的内容。当您执行CSV.read()
时,默认情况下会返回CSV.Column
类型的不可变列。这样做是出于性能考虑,因为这意味着在解析后不必复制列。