I have a suspicion that tryparse, which can return all kinds of data types, might be forcing a conversion to DataValue{Any}. I’ll see if I can make that type-stable and see what results.
learning … learning…
Indeed:
dflong2 = DataFrame(dflong |> @mutate(year = something(tryparse(Int,string(_.variable)[end-3:end]),0)))
display(first(dflong2,10))
gives a table with proper data types.
In this case it’s OK to encode meaningless data as 0. But I find it weird that I lose ALL type info rather than just the particular column “year”.