Plots borking on SentinelArrays produced by CSV.read

I came across this post

which recommends reading the CSV single-threaded. That works:

julia> wwdat1 = CSV.read("NWSSSarsCov2WastewaterConc.csv",DataFrame; ntasks = 1)
335417×4 DataFrame
...

julia> wwdat1.key_plot_id |> typeof
       # now it's a normal Vector, not a SentinelArray type
Vector{String} (alias for Array{String, 1})

julia> scatter(wwdat1.date,wwdat1.pcr_conc_smoothed) ## works.

Screenshot_20221030_113317

The same thread also suggests collecting the column before plotting, as another way of managing this, and that works too:

julia> scatter(collect(wwdat.date), collect(wwdat.pcr_conc_smoothed))  # works

But reading the CSV with ntasks = 1 is a fixed, one-time (per session) cost, so that’s probably better than collecting for every plot call.

1 Like